H  32  32.1  33  34  35  36 

Hands-On: Flash MX 2004 ActionScripting

Exercise 32.1: Actions That Loop Parts Of Your Movie Clip

  1. In a new file, use the Text tool to create a text block at 28pts tall containing the words SomaliaExtraordinaire. Save this file as: MX2004_ActionScripting-Loops.fla
  2. Select the Text block and convert to a Movie Clipsymbol [Ctrl] + [F8]. Name it "wine_expert".
  3. The Align Panel Position the clip instance in the center of the screen, select Windows > Design Panels > Align, (or [Control] + [K]) and then click the To stage: icon. Then Click both of the middle icons in the Distribute: row.
  4. Insert keyframes [F6] at frame20 and frame 30.
  5. Move the red current frame marker to frame 1 and move SomaliaExtraordinaire text all the way off the stage to the left. Try holding the [Shift] key down while pressing the Left Arrow key, it will move quite quickly.
  6. In the Properties Inspector panel set Motion Tweening for both frame 1 and frame 20.
  7. Place the red current frame marker in frame 20, and then use the Properties panel to make the tween rotate one time clockwise (CW) on it way from frame 20 to frame 30.
  8. Test the movie. Notice that the whole movie loops over and over. Instead we're going to make the rotation part (from frame 20 to frame 30) loop forever.
  9. The Timeline and Actions Panel together In the Timeline rename the first layer "animation" and then choose Insert > Layer and name the new one "actions."
  10. Make sure the current layer is actions (you'll see a pencil in the layer).
  11. Select frame 30 in your Actions layer, insert a keyframe [F6], and then access the Actions panel (either by selecting Window >Development Panels >Actions or press [F9].
  12. Make sure frame 30 remains selected when you edit the Actions panel. We're going to set an Action to execute when the playback head reaches frame 30.
  13. Click the plus button and then Global Functions > Timeline Control > gotoAndPlay and then type 20 in between the parentheses (20).
  14. Notice that in the Timeline, a small “a” appears in the keyframe where you added the Action.
  15. The Timeline for Actions
  16. Test the movie (don't just play in the authoring environment). It plays once, and then every time it gets to frame 30 it goes back to frame 20 and plays again.

There is a better way to accomplish the above so that if you change the frames for better timing, you don't mess up your animation.

Instead of making the destination of your gotoAndPlay an explicit frame number, you can change the parameters to make the destination a named frame label, which will be the same for the frame no matter where it is located in the Timeline.

 

Back to Top