Task: Animation Playback Controller

I l @ ve RuBoard

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. 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.

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


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

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

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

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

     on (release) {     gears.stop(); } 
  9. 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.

     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.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

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