Flash Tutorial on MovieClip Buttons By John Riddle

 

In this tutorial I will discuss how to make a button that when you click it it goes to another frame and plays the rest of the clip so you can use this to make your page a little more interactive.

 

1.    First you just need to make any shape and convert it to a symbol and name it ÒButtonÓ also down in the property inspector, give the button an instance name.  call it ÒBTNÓ.  You will do all of this on frame 1 in the timeline.

2.    Now create another layer called Òmy movieÓ and create whatever it is you would like to play when you click the button on frame 2 of the main timeline.

3.    Create another layer in the timeline called Actions.

4.    Go into the actions layer on frame 1 of the main timeline and open up the action script panel. Now type

 

     Stop();

 

      5.Now we are going to place the code in the action layer for the button you already created called ÒbuttonÓ and with the instance name of ÒBTNÓ.

 

6.  This is the exact code you need to type in the actions panel for the button to work on frame 1 in the actions layer.

 

 

BTN.addEventListener(MouseEvent.CLICK,moviebutton);

 

function moviebutton (event:MouseEvent):void

{

    gotoAndPlay(2);

}

 

To explain the code above.

 

BTN.addEventListener(MouseEvent.CLICK,moviebutton); takes the instance name and sets it up to be on the look out for a mouse click so when that button is clicked it runs the function ÒmoviebuttonÓ.

 

You can also make numerous buttons with these same actions.

 

The same code can be applied with a gotoAndStop();