Tags

, , , , , , ,

 

One of the most basic of creations needed in any game, even if it is just to start the game. But somehow, it can be easily got wrong.

Step 1 – create your button.

1. Insert a new layer and name it.
2. Click on desired keyframe and create button shape.
3. Click button shape and Convert to Symbol – f8
4. Choose Button and give it a name. Ensure registration point is central.
5. Click OK. Button is now stored in the library; and can be reused over and over again.

Step 2 – edit your button

1. Double click on the button. The button editing window will appear.
2. In the button editing window, there are 4 important frames: Up, Over, Down, Hit. (Up – The normal stage of the button. Over – The stage where the user places a cursor on it (hover). Down – The stage where user clicks the mouse. and Hit – this is the area in on the button which is clickable to the user; you should always allow this to remain as it is.)
3. By default, the button just created will be in the Up frame.
4. Convert the shape in the Up frame into Movie Clip if you want to allow for customisation with effects. (not necessary though just makes it look good)
5. Duplicate the Up frame into Over, Down & Hit by inserting keyframes.
6. Customise the design for each of the frame except for the Hit stage.
a. Any Text to be used on the button should go in a separate layer.
7. After customisation, click the Scene link to go back to the main page.
8. Test the movie by going to Control > Test Movie > Test.
9. Button should now respond to Mouse over and Mouse click.

Step 3 – the ActionScript

button_btn.addEventListener(MouseEvent.CLICK,clickbutton_btn);
function clickbutton_btn(event:Event):void
{
// put your actionscript for the button in here
// it could be as simple as going to a specific frame
gotoAndPlay(4);
}

And there, your button is finished. Easy, right?

 

Advertisements