• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Advanced Buttons and Event De... > Animated Buttons and the Movie-Clip ...

Animated Buttons and the Movie-Clip Symbol

Animated buttons display an animation in any of the first three keyframes (Up, Over, and Down) of the button symbol. A button can spin when the pointer rolls over it, for example, because you have an animation of the spinning button in the Over state. How do you fit an animation into only one keyframe of the button symbol? The answer: Use a movie clip.

A movie clip is a special kind of symbol that allows you to have animations that run regardless of where they are or how many actual frames the instance occupies. This feature is possible because a movie clip’s Timeline runs independently of any other Timeline, including other movie-clip Timelines and the main movie Timeline in which it may reside. This independence means that as long as you establish an instance on the Stage, a movie-clip animation will play all its frames regardless of where it is. Placing a movie-clip instance in a keyframe of a button symbol makes the movie clip play whenever that particular keyframe is displayed. That is the basis of an animated button.

An animation of a butterfly flapping its wings, for example, may take 10 frames in a movie-clip symbol. Placing an instance of that movie clip on the Stage in a movie that has only one frame will still allow you to see the butterfly flapping its wings (Figure 4.19). This functionality is useful for cyclical animations that play no matter what else may be going on in the current Timeline. Blinking eyes, for example, can be a movie clip placed on a character’s face. No matter what the character does—whether it’s moving or static in the current Timeline—the eyes will blink continuously.

Figure 4.19. Movie clips have independent Timelines.

To create a movie clip:

From the Insert menu, choose New Symbol.

The Symbol Properties dialog box appears.

Type a descriptive name for your movie-clip symbol, choose Movie Clip as the behavior, and click OK (Figure 4.20).

Figure 4.20. Create a new movie-clip symbol by naming it and selecting the Movie clip behavior.

You will enter symbol-editing mode.

Create the graphics and animation on the movie-clip Timeline (Figure 4.21).

Figure 4.21. The pondRipple movie-clip symbol contains two tweens of an oval getting bigger and gradually fading.

Notice how the path above the Timeline tells you that you are currently editing a symbol.

Return to the main Stage.

Your movie clip is stored in the Library as a symbol, available for you to bring onto the Stage as an instance (Figure 4.22).

Figure 4.22. Bring an instance of a movie clip symbol onto the Stage by dragging it from the Library.

✓ Tip

  • New instances of movie clips begin playing automatically from the first frame, as do instances in different scenes. Imagine that you build a movie-clip animation of a clock whose hand makes a full rotation starting at 12 o’clock. If you place an instance in scene 1 and continue your movie in scene 2, Flash will consider the instance in scene 2 to be new; it will reset the movie-clip animation and begin playing the clock animation at 12 o’clock.

To create an animated button:

Create a movie-clip symbol that contains an animation, as described in the preceding task.

Create a button symbol, and define the four keyframes for the Up, Over, Down, and Hit states (Figure 4.23).

Figure 4.23. A simple button symbol with ovals in all four keyframes.

In symbol-editing mode, select the Up, Over, or Down state for your button, depending on when you would like to see the animation.

Place an instance of your movie-clip symbol on the Stage inside your button symbol (Figure 4.24).

Figure 4.24. The Over state of the button symbol. Place an instance of the pondRipple movie clip in this keyframe to play the pond-ripple animation whenever the pointer moves over the button.

Return to the main movie Timeline, and drag an instance of your button to the Stage.

From the Control menu, choose Test Movie.

Your button instance plays the movie-clip animation continuously as your pointer interacts with the button (Figure 4.25).

Figure 4.25. The completed animated button. When the pointer passes over the button, the pond-ripple movie clip plays.

✓ Tips

  • Stop the continuous cycling of your movie clip by placing a stop action in the last keyframe of your movie-clip symbol. Because movie clips have independent Timelines, they will respond to frame actions. Graphic symbols do not respond to any frame actions.

  • To better organize animated buttons, it’s useful to create a new layer in the Timeline of your button symbol and reserve it specifically for the animation (Figure 4.26).

    Figure 4.26. A new layer in the button symbol Timeline helps organize the animation.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint