Add an Action to a Movie Clip

 < Day Day Up > 



Adding an action to a Movie Clip is similar to adding to a frame or a button. In this exercise, you add the ActionScript to one of the e-cards being made for the Habitat Alert Web site. You can get the starter file (ecard2_start.fla) from the chapter28_exercise folder on the CD-ROM. Take a moment to look at each frame. You'll notice that Frame 1 contains a cartoon heron and some eggs. If you open the Library (F11), you'll see that each egg is a Movie Clip symbol. Click Frame 2, and you'll see a text area with information about the Great Blue Heron. Continue to check the other frames. Each one has text added for the various eggs. What you will be doing is adding ActionScript with the corresponding text to each egg. The text will appear when the user clicks the egg. The last frame for the goose egg is a joke, as in being goosed. (In Chapter 29, you learn how to add a squawk sound to the goose link.) To add the ActionScript to the e-card, follow these steps:

  1.  Habitat Alert site   Open the  ecard2_start.fla file from the chapter 28_exercise folder.

  2. Select the first large egg marked Great Blue Heron.

  3. Open the Actions panel (F9) and use Normal mode.

  4. In the Actions toolbox, open the Actions category and the Movie Control category. Double-click the on action.

  5. Notice the Script pane and that on (release) has been added. You want the frame to change on rollover. In the Parameters pane the only parameters available are events. Select Roll Over and deselect Release.

  6. The ActionScript in the Script pane has changed to

    on (rollover) { } 
  7. Now you need to tell the ActionScript what you want to happen on rollover. In this case, you want it to go to Frame 2 and stop so you can read it. To do this, double-click the goto action in the Movie Control category of the ActionScript toolbox.

  8. In the Parameters pane, click the Goto and Stop radio button. In the Frame field enter the number 2. The script now looks like this:

    on (rollover) { gotoAndStop(2); }
  9. The rollover works, but what happens when the user moves the cursor away from the egg? As it is now, nothing happens. You want the movie to return to Frame 1 when the cursor moves off the egg. Select the curly bracket ({) in the last line of code in the Script pane.

  10. Double-click the on action again. In the Parameters pane, select Roll Out and deselect Release.

  11. Double-click goto, select Goto and Stop, and enter 1 in the Frame field.

  12. Test the movie (Control+Enter [Command+Enter]).

    The movie plays through all the frames. You have correctly entered the ActionScript for the rollover, but now you need to have the movie stop at Frame 1. Select Frame 1 and double-click the stop action in the Movie Control category. Now test your movie. Mouse over the first egg and then move your mouse away.

  13. Repeat for the remaining eggs adding a stop action to each frame of the movie. For the second egg (Great Egret) you want to go to Frame 3. The goose egg goes to Frame 6. Remember that the first goto is going to the frame that holds the text for that particular egg.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net