H  32  32.1  33  34  35  36 

Hands-On: Flash MX 2004 ActionScripting

Exercise 33: Using Frame Labels as the Destination of a GoTo

Use the file: MX2004_ActionScripting-Loops.fla, and let's make life a bit easier for you.

  1. In the file you just finished, click frame 20 of the Animation layer. In the Properties panel you should see a place where you can type a frame label. Label this frame "loop_start".
  2. 1 2
  3. Go back and click on frame 30 in the Actions layer and open the Actions panel.
  4. Goto and Play at frame or label dilaog box.This time you will be using the Frame Label in the ActionScript. Delete the current ActionScript in Frame 30 so you can try this technique.
  5. Click Window > Development Panels > Behaviors or [Shift] + [F3] to open the panel.
    Behaviors for Movie Clip
  6. Click the down arrow at the bottom of the Plus Mark + symbol and choose Movieclip > Goto and Play frame or label. In the dialog box type loop_start.
  7. This is what the code looks like now, notice the //comment tags Flash MX 2004 added for you to describe what is going on in the ActionScripting.
  8. Viewing the Actions coding.
  9. Test the movie; it doesn't look any different to the user, but there is a good reason to do this for yourself. If for any reason you decide to move the starting frame for the looping animation, you will have to change the Frame number as well, using a Frame Label eliminates this since the ActionScript will look for the label instead.
  10. Now go back to the Timeline and click and drag the loop_start keyframe to frame 10.
    Frame label in the Timeline
  11. Test the movie again. The animation now loops back to frame 10, where you moved the loop_start keyframe. This little trick will help you work with your movies without any additional grief!
  12. Save your file for additional exercises.

So this is what you’ve learned so far:

  • Actions are instructions that we want Flash to follow.
  • Actions do things. You can modify Actions by changing their parameters.
  • The three places you can put Actions are in: keyframes, on Button instances, and on Movie Clip instances.
  • We just did a couple of exercises with frames, if you put an Action in a frame, it will not be followed until the playback head reaches that frame.
  • This is not interactivity with the user, it happens all by itself.
  • If you wanted an animation to stop by itself, all you'd need to do is place a keyframe where you want it to stop and add a Stop Action.

 

Back to Top