Unlike most multimedia authoring applications, Flash has the capability to use multiple timelines simultaneously. So far, most of the examples in this book have only one timeline and one scene. You’ve seen how to add basic actions to your movies to make them interactive. Now, we begin exploring the world of multiple movie timelines using the Movie Clip symbol.
A powerful addition to Flash was the Movie Clip symbol, which was introduced in version 3. Movie Clips enabled Flash developers to create complex behaviors by nesting self-contained sequences of animation or interactivity inside each other. These sequences could then be placed as discreet, self-playing modules on the Main Timeline. The key to the power of Movie Clips was their capability to communicate with and control each other via the Tell Target action. In Flash 4, the role of Movie Clips was expanded—they could be used with Action Script. That capability put Movie Clips at the foundation of advanced interactivity in Flash.
How Movie Clips interact within a Flash movie
Whether the playback along that timeline was linear (traditional animation) or nonlinear (where the Playhead jumps arbitrarily to any frame), our example movies have normally comprised only the frames of a single timeline. Ostensibly, a single timeline may seem to provide everything you’d need to create any Flash behavior, but as you get more inventive or ambitious, you’ll soon find yourself conceiving ideas for animated and interactive segments that are thwarted by the limits of a single timeline.
Suppose you want to create a looping animation of a character’s face. You decide that the character’s eyes should blink every 2 seconds, and that the character’s mouth should yawn every 15 seconds. On a single timeline, you’d have to have a loop of 180 frames for the mouth (assuming a frame rate of 12 frames per second), and repeating keyframes for the closed eye artwork every 24 frames. Although creating your face in that manner would be a bit cumbersome, it wouldn’t be impossible until your character’s face had to move around the screen as an integrated whole. Making the mouth and eyes loop while the whole face moved around complex paths for extended periods of time would quickly become impractical, especially if the face were only one part of a larger environment.
Now imagine that you could make your character’s face by creating two whole separate movies, one for the eyes and one for the mouth. Could you then place those movies as self-contained animating objects on the timeline of your main movie, just like a graphic or a button? Well, you can that’s what Movie Clips are all about.
Movie Clips are independent sequences of frames (timelines) that can be defined outside the context of the main movie timeline and then placed onto it as objects on a single frame. You create Movie Clips the same way you create a Graphic symbol (in the Edit Symbol environment). Unlike a Graphic symbol, a Movie Clip (as the name implies) acts in most cases just like a fully functional .SWF file, meaning, for instance, that frame actions in Movie Clip timelines are functional. After you have created a Movie Clip as a symbol, you drop instances of it into any keyframe of the main movie timeline or any other Movie Clip timeline. The following are some general Movie Clip principles:
- During playback, a Movie Clip instance placed on a timeline begins to play as soon as the frame on which it occurs is reached, whether or not the main movie is playing.
- A Movie Clip plays back autonomously, meaning that as long as it is present on stage it is not governed by the playing or stopping of the Main Timeline.
- Movie Clips can play when the Main Timeline is stopped, or stay halted when the Main Timeline plays.
- Like a Graphic or a Button symbol, Movie Clips can be manipulated on the stage you can size them, skew them, rotate them, place effects such as Alpha blending on them, or tween them, all while the animation within them continues to play.
- All timelines play at the frame rate specified by the Modify Movie dialog. However, it is possible to control a timeline’s frame rate with ActionScript routines.
In our character face example, the animated eyes and mouth could be looping Movie Clips, and then those movie clips could be grouped and tweened around the Stage on the Main Timeline to make the whole face move. The same principle could be used to move a Movie Clip of a butterfly with flapping wings along a motion path.
One movie, several timelines
Because a Flash movie can have more than one timeline existing in the same space and time, there needs to be away of organizing Movie Clips within the Main Timeline (Scene 1) of your Flash movie. Just like artwork can be placed inside of any symbol, symbol instances can be “nested” within other symbols. If you change the contents of the nested symbol, the parent symbol (the symbol containing the other symbol) will be updated as well. Although this may not seem special, it’s of extreme importance to movie clips and Flash interactivity. Because the playback of each Movie Clip timeline is independent from any other timeline, you need to know how to tell Flash which Movie Clip you want to control.
The Flash movie diagram multiple timelines. This Flash movie has two layers on the Main Timeline, Layer 1 and Layer 2. Layer 1 has a Movie Clip (instance “A”) which exists for 19 frames on the Main Timeline. Layer 2 has a Movie Clip (instance “B”) which exists for 10 frames on the Main Timeline, but also contains a nested Movie Clip (instance “C”).
one method of diagramming Flash timelines.
Above, if the Main Timeline has a Stop action on the first frame, then all three Movie Clips will continue to play unless there are Stop actions on their first frames or they are told to stop by actions targeted to them. If the Main Timeline plays to frame 20, then instance “A” will no longer be on the Stage, regardless of how many frames it may have on its timeline. A more practical diagram of a timeline hierarchy can be found below.
Flash movies can be flow-charted in this fashion. This diagram is similar to the new Movie Explorer’s method of displaying Flash movie information.
Above, you can see three Movie Clips. Two of them, ballAnim and dog, occupy space on the Main Timeline. The other one, dogTailAnim, is nested within the dog Movie Clip. Each Movie Clip instance on any given timeline needs to have a unique name you can’t have the two Movie Clip instances on the same timeline with the same name. The instance name is specified in the Instance Panel, shown below.
Among other things, the Instance Panel enables you to name each Movie Clip instance that appears on the Stage.
Now that you understand how multiple timelines can exist within a Flash movie, let’s see how you can make Movie Clips communicate with one another.