Flash CS4

Page 304

20_381199-ch12.qxp

282

8/22/08

10:08 AM

Page 282

Part V: The Movie and the Web myButton1 is the instance name of the first button that you created in Step 4, and myFrameLabel1 is the name of the first frame label you created in Step 9. In the preceding code, menuChoice is defined as a function that moves the playhead of the Timeline of the current movie to the myFrameLabel1 frame and stops. After the function definition is the statement that connects an event listener that “listens” for a rollover to the button that has the instance name myButton1. When the mouse rolls over the button, the event listener calls the function menuChoice1. 1 6 . Select Frame 1 in the myCode layer in the T imeline and enter this additional code in the Script pane of the Actions panel: function menuChoice2(event:MouseEvent):void { this.gotoAndStop(“myFrameLabel2”); } myButton2.addEventListener(MouseEvent.ROLL_OVER, menuChoice2);

This code connects the second button that you made to an event listener and an event handler. 1 7 . For each additional button that you made, r epeat Step 16 to add mor e code to Frame 1 in the myCode layer in the T imeline. Substitute the new button’s instance name for myButton2.. Substitute the new destination frame’s label for myFrameLabel2.. And substitute a new func tion name for menuChoice2.. 1 8 . Choose Contr ol➪T Test Movie to tr y it out! When you roll over a button, the graphics, text, and movie clip animation on the appropriate frame appear. Figure 12-10 shows a Timeline with frames that are displayed when the mouse cursor passes over buttons. If you use CLICK rather than ROLL_OVER in Steps 15 and 16, you can display different information when the mouse clicks each button.

Figure 12-10: When the user moves the mouse over each button, the movie will jump to a different Frame Label on the Timeline.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.