Adding a Start Button
Most games start with an introductory animation. In this section, we create a simple starting frame for our game (Fig. 17.1(a)).
Select the first frame of the Intro/End layer. From the Library, drag the introText movie clip and the Play button onto the stage. Resize and position both objects any way you like. Set the Play button’s instance name to playButton. Don’t worry that introText is invisible when deselected; it will fade in when the movie is viewed.
Test the movie. The text effects were created by manipulating alpha and gradient values with shape tweening. Explore the different symbols in the Library to see how they were created. Now, in the first frame of the Actions layer, add the code shown in Fig. 17.4 in the Actions panel. When the Play button is clicked, the movie will now play the second frame, labeled game.
1 // Fig. 17.4: Handle playButton click event.
3 // call function playFunction when playButton is clicked
4 playButton.addEventListener( MouseEvent.MOUSE_DOWN, playFunction );
6 // go to game frame
7 function playFunction( event : MouseEvent ) : void
9 gotoAndPlay( "game" );
10 } // end function playFunction
Fig. 17.4 | Handle playButton click event.
Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.