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

Chapter 4. Advanced Buttons and User Inp... > 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. For example, a button can spin when the pointer rolls over it because there's an animation of the spinning button in the Over state. How do you fit an animation in only one keyframe of the button symbol? The answer is to use a movie clip.

Movie clips are a special kind of symbol that allow you to have animations that run regardless of where they are or how many actual frames the instance occupies. This 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 of 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.

For example, an animation of a butterfly flapping its wings may take ten 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.11). This functionality is useful for cyclical animations that play no matter what else may be going on in the current Timeline. Blinking eyes, for instance, can be a movie clip placed on a character's face. No matter what the character does—whether moving or static in the current Timeline—the eyes will blink continuously.

Figure 4.11. Movie clips have independent Timelines.

The movie clip is unique in that it is also a Flash object. This means that along with its independent Timeline, the movie clip has methods and properties you can control with an action script. You'll learn how to control a movie clip's Timeline as well as its methods and properties in the upcoming chapters. For now, we'll look at how to use a movie clip in the context of buttons.

To create a movie clip:

From the Insert menu, choose New Symbol.

The Symbol Properties dialog box appears.

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

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

You will enter symbol-editing mode.

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

Figure 4.13. The pond ripple movie clip symbol contains two tweens of an oval getting bigger and gradually fading.

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

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


New instances of movie clips will automatically begin playing from the first frame. This also applies to instances in different scenes. For example, 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 as new, and 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 previous task.

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

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

Select either the Up, Over, or Down state in the Symbol-Editing mode of your button, depending on when you would like to see the animation.

Comparing a Movie-Clip Instance with a Graphic Instance

How does a movie clip instance differ from a graphic instance? If you create the same animation in both a movie clip symbol and a graphic symbol, and then place both instances on the Stage, the differences become clear. The graphic instance shows its animation in the authoring environ ment, displaying however many frames are available in the main Timeline. For example, if the graphic symbol contains an animation lasting ten frames and the instance occupies four frames of the main Timeline, then you will see only four frames of the animation. Movie clips, on the other hand, do not work in the Flash authoring environment. You need to export the movie as a SWF to see any movie clip animation or functionality. When you do export the movie, Flash plays the movie-clip instance continuously, regardless of the number of frames the instance occupies, and even when the movie itself has stopped.

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

Figure 4.16. The Over state of the button symbol. Place an instance of the pond ripple 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 on the Stage.

From the Control menu, select Test Movie.

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

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


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

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