Getting to Know Flash Pro - Timelines
(Page 4 of 9 )
You can best envision multiple Timelines by thinking of the base movie as a movie clip. Each movie clip has its own Timeline. The main Timeline can be addressed as the root level using the root property. However, because each level has its own root level, the base movie is best addressed as level0. If you load a movie clip into level 25 (_level25), any address to _root will go to the root of level 25. To address the root level of the movie (_level0), from level 25 or any other level, just use _level0 instead of _root.
The Many Roots in Flash - In Flash MX Professional 2004, you can set any movie clip to the root level by using MovieClip._lockroot, where MovieClip is the instance name of the movie clip. All movie clips loaded into the movie clip with the _lockroot property reference that movie clip using _root. In other words, _lockroot makes that movie clip the base Timeline for all movie clips inside it.
To understand Timeline addressing, imagine an airplane movie clip. The movie clip has the instance name airplane sitting on the root level. Inside the airplane movie clip is an engine movie clip, and inside the engine movie clip is a propeller movie clip. To address the propeller, you could use either of the following paths:
_root.airplane.engine.propeller
or
_level0.airplane.engine.propeller
Essentially, when the _levelN property is employed, it's the same as writing "go to the root of this level." This technique is far clearer when you're debugging a script.
Levels If you have multiple levels in a movie, the root level is whatever the level assigned to the movie clip to be loaded is. So if you load a movie clip on level 12, the root level is assigned the property _level12. Using the airplane movie clip example from the preceding section, you could address the propeller movie clip as either of the following:
_root.airplane.engine.propeller
or
_level12.airplane.engine.propeller
As you can see, the reference to _root can be confusing because every level has its own _root property. However, _level12 clearly specifies the main Timeline for that level. The developer specifies the level for the movie clip or loads it into a known level in a given application and thus knows the movie clip's level. New levels are created only when an external movie clip is loaded, an existing movie clip is duplicated, or one is created using the MovieClip class. If a movie clip is loaded to or assigned _level0, the base movie is replaced by the one loaded to _level0. Likewise, if a movie clip is assigned the same level of any other level where a movie clip currently exists, the loaded clip replaces the clip that was assigned the same level. Figure 1.11 shows the basic relationship between a main movie and movie clips loaded at different levels.
For further details on working with movie clips on different Timelines and levels, see Chapter 5, "Movie Clip Control."

Figure 1.11 Levels and Timelines.
Scenes A scene in Flash is a separate area where a new set of materials can be placed. The scene is an organizational tool more than a literal "scene." For example, whenever a background color is changed in one scene, all scenes get the same background color. On the other hand, each new scene has none of the images of a previous scene, and each starts with Frame 1.
Frames in scenes have two different addressing modes: absolute and scene relative. Because scenes are an extension of a sequence of frames, they can be addressed as the absolute number relative to the number of frames in the entire movie. If you imagine a reel of film filled with several scenes, each frame has a distinct value beginning with 1 and ending with the total number of frames in the reel. Likewise, if you refer to a frame by its position relative to a scene, you can refer to "Scene 5, Frame 7," for example. If each scene has 100 frames, you could refer to the same frame as Frame 507.
Because you address frames only by using ActionScript, such as when you're using the gotoAndPlay() and gotoAndStop() global Timeline control functions, all references must be through ActionScript. No equivalent setting for Timeline control is possible without using ActionScript. A frame in Scene 5, Frame 7 would be addressed like this:
gotoAndPlay(³Scene 5²,7);
If each scene is 100 frames in length, the same position on the Timeline can be addressed as follows:
gotoAndPlay(507);
Like frames, scenes can have descriptive names that you supply using the Scene panel. For example, the following script illustrates how a scene with a descriptive name and labeled frame provide a clear path:
gotoAndPlay(³PlanetVenus², ³landing²);
Using descriptive names for both frames and labels helps you keep track of everything in your animation.
The Titanic Had It Coming - As a professional development and design tool for creating rich Internet applications (known as RIAs), Flash has no peer. Flash was originally designed with the dual goals of enabling the development of animation and doing so at the lowest possible bandwidth costs. Early Flash users, especially hobbyists, made a point of adding animations to every page, to the extent that the blinking, bouncing, and whirling creations were enough to unnerve a tree sloth. Such superfluous moving noise, known unaffectionately as dancing baloney, was blamed on Flash and not the near-crazed developers whose boggled minds created these abominations. Critics rightfully pointed out that such animated junk had no place in professional work, intimating that were Flash removed from the hands of developers and designers, the world would be safe for good Web usability.
In addition to creating annoying animations, Flash designers took to creating huge files that lumbered across the Internet at the pace of a hesitant slug. Having learned that vector graphics, especially used in conjunction with symbols, made for smaller files and faster Internet transfer, designers somehow got the idea that an unlimited number of graphics could be animated and quickly displayed on a user's monitor. (For good measure, many of the same designers concluded that if Flash were fast, it would be able to handle bitmapped graphics just as quickly.) When tested on their own computers, the Flash movies appeared lickety-split.
Fortunately (or unfortunately), grave developers cautioned designers about bandwidth usage and handed them the infamous preloader. With a preloader, designers could create gargantuan files and, while waiting for these files to load, the users could entertain themselves looking at a preloader animation informing them that their file was loading but not quite ready yet. Unfortunately, neither the developers nor the designers were aware that Attention Deficit Disorder is the norm rather than the exception among Web surfers, and so most of these digital tomes were never viewed by anyone other than the designers themselves. Therefore, as a professional development tool, Flash was suspect.
Since these early days of Flash, both the product and its developers have matured. Good usability was built in with the introduction of UI components, and designers began to realize the importance of using animation judiciously as well as keeping the file size down. Preloaders are likely to be found when loading a portion of a Flash movie, and impatient users only have to suffer a few seconds awaiting the next part of the movie to play. Additionally, many parts of a Flash movie can be loaded progressively so that, after only a moment of buffering, MP3 sound files and FLV movie files begin playing. Rather than being viewed as a tool to create ponderous files on the order of Jabba the Hutt, Flash Pro is much more the orchestra conductor bringing together many different parts to seamlessly inform users and help them get what they want from the World Wide Web.
This chapter is from Macromedia Flash MX Professional 2004, by Bill Sanders (Sams, 2004, ISBN: 0672326051). Check it out at your favorite bookstore today.
Buy this book now. |
Next: Flash Files >>
More Flash Articles
More By Bill Sanders