Home > Articles > Graphics & Web Design > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

Task: Animation Playback Controller

Now let's put this knowledge to work. In the example movie 06animationplayback.fla there is a movie clip named "gears". Other elements on the main timeline are buttons that will control this movie clip.

The "gears" movie clip is nothing special. It contains 60 frames of animation. No scripts or markers are in it at all.

The goal here is to build a movie that controls the movie clip completely. It allows the user to click buttons to advance the movie clip frame-by-frame, play the movie clip at its normal rate, stop the movie clip, and send the movie clip back to the first frame.

  1. Create a new Flash movie. Create movie clip animation in it, or simply steal the "gear animation" movie clip from the sample movie.

  2. Drag the movie clip from the Library to the work area. Choose Windows, Properties so that you can change the name of the movie clip to "gears".

  3. Place a script in the first and only frame of the main timeline. This script prevents the movie clip from animating when you first run the movie:

  4. gears.stop();
  5. Create a set of buttons. You will need a button for the following actions: Advance, Previous, Play, Stop, and Rewind. Place them all in the work area under the movie clip. Figure 6.2 shows how this looks in the sample movie.

  6. Figure 6.2 The sample movie features a movie clip animation and five buttons.

  7. The Advance button uses the nextFrame command, addressed to the movie clip, to advance the clip one frame at a time.

  8. on (release) {
      gears.nextFrame();
    }
  9. The Previous button uses the prevFrame command, in the same manner, to move the movie clip back one frame.

  10. on (release) {
      gears.prevFrame();
    }
  11. The Play button uses the play command to let the movie clip advance and loop as it would normally.

  12. on (release) {
      gears.play();
    }
  13. Likewise, the Stop button issues a stop command to the movie clip.

  14. on (release) {
      gears.stop();
    }
  15. The Rewind button does something a little different. It uses the gotoAndStop command to send the movie clip back to Frame 1 and have it wait there.

  16. on (release) {
      gears.gotoAndStop (1);
    }

    Test this movie. If none of the buttons seem to work, the most likely reason is that the movie clip is not named properly.

Imagine this same example movie, but with a cartoon or other animation instead of the simple one here. The Flash movie then acts like a viewer for the animation.

  • + Share This
  • 🔖 Save To Your Account