Friday, October 31, 2014

EQ # 11

To add a button, you must first create the button.

Do this by creating a shape and adding the text, if you want any.
Then you have to select it all and go to Modify --> Convert to symbol.
Then you go to library and drag the button to the desired place.
With the button still selected, create a new layer and go to the action tab.

You then type the following code:

stop();

myButton.addEventListener(MouseEvent.CLICK, myButtonClick);

function myButtonClick(ev:MouseEvent):void
{
gotoAndPlay(-);
}

(Replace the - with the frame number)

For every button, you must create a different instance name.

Here is an example of two button codes:

stop();

myButton1.addEventListener(MouseEvent.CLICK, myButton1Click);

function myButton1Click(ev:MouseEvent):void
{
gotoAndPlay(4);
}



stop();
myButton2.addEventListener(MouseEvent.CLICK, myButton2Click);

function myButton2Click(ev:MouseEvent):void
{
gotoAndPlay(5);
}

No comments:

Post a Comment