Understanding layers, levels and depths
How are Layers, Levels and Depths different?
Sometimes people use the term layer and level interchangeably, but they are not the same at all.
Timeline There are two ways a timeline can be independent of the main timeline: it can be a Movie Clip, or a Level. By independent we mean that you can start and stop them independently (as well as affect them in other ways.) You can stop the main timeline, for example, and the independent timelines will continue playing, or you can stop a clip or level as the main timeline continues playing.
Layers are the stack you see in the authoring tool, within a single timeline, used to keep apart separate objects which share that timeline. They really only exist in the authoring tool - when you publish a Macromedia Flash SWF file, Flash "flattens" out the layers into a single timeline.
Levels are a stack of independent timelines that are movies (SWF) stored outside the main movie, and brought in with the loadmovie action. (For a good primer on loadmovie, see How To Use Load Movie (TechNote 14190).
Levels are referred to by their stacking order as _level0 _level1 _level3 and so forth. The higher the number, the "closer" it is to the viewer, visually. A movie loaded in that way exists throughout the entire timeline of the main movie. For this reason, a popular use for a loaded movie is a soundtrack which plays continually regardless of what the main movie is doing.
Movie Clips are are also independent timelines. The clip itself resides in the library, not of outside your movie. Unlike a movie loaded into a level, you can have an instance of a movie clip exist in only the frames you want it to.
When you take a clip from the library and place it on the stage, you're actually creating a reference to the clip (an "instance") You can bring many "copies" of the same clip onstage, and give each instance its own unique name, so that you can refer to each one specifically. This allows you to start/stop a clip and so forth, independently of the others. Clips can contain clips, which can in turn contain clips - known as nesting.
Depth, as used in the movieClip.swapDepths() and movieClip.attachMovie methods, refers to a stacking order of movie clips; it can be thought of as the z-axis (front-to-back) position of a clip. It is similar to when you are placing symbols onstage on a single layer - some things are "in front" of other things. The higher the number, the "closer" the clip is to the viewer. Think of it as an programmable way of doing Modify>Arrange. Note that while depth, appearence-wise, is similar to a timeline's layers, or levels of independent timelines, depth is not the same thing as either layer or level.In referring to clips you still need to refer to them by their instance names.
Depths are timeline-relative. Depth refers to the stacking order within a given timeline. An object on _level1 will always appear above an object on _level0, irrespective of what the depth the object is set to. Likewise inside a timeline, any objects nested inside a clip on that timeline on a higher-numbered layer, will always appear in front of objects at lower-numbered layers.
Another sense of the word "Depth." You will sometimes hear Flash developers refer to "depth" in terms of a clip-within-a-clip (nested depth,) as seen in the Movie Explorer tree structure. This is not the same as a clip's "depth" visually. When discussing depths of this nature, it is recommended that you refer to the "nested depth" to avoid confusion about terminology.
.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
