_leveln Global Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
_leveln Global Property

a document level in the PlayerFlash 3 read-only
_level0 _level1 _level2 ... _leveln

Description

Multiple .swf files can be loaded into the Flash Player for simultaneous display. Each loaded .swf can be placed in a movie clip or on its own "level" in the document level stack. The _leveln property stores a reference to the main timeline of a .swf loaded into a document level in the Player. Each document level is represented by a numbered property, such as _level0, _level1, _level2, and so on. A .swf file on a higher level will obscure lower levels if they occupy the same portion of the Stage. The original document loaded into any Flash Player is considered _level0.

Note that _leveln is not always synonymous with _root; _root refers to the main timeline of the current movie, while _leveln refers to the main timeline of a movie on a specific document level. To create global variables that are available from any document level, use _global.

Example

A _leveln reference normally is used to control movies on other levels of the document stack. For example, here we play the movie on level 2:

_level2.play();

We can also use _leveln in combination with movie clip references to control clips contained by a movie on any level in the document stack. For example:

_level1.orderForm.titleBar.play();

A _leveln reference may also be used as the value of the target argument of several functions, including loadMovie( ), unloadMovie( ), loadVariables( ) and print( ). If the level does not yet exist, you should specify the level reference within quotes. If used without quotes, a nonexistent level is considered undefined and may cause the command to operate on the current timeline instead of the new, undefined level. For example, when executed from the main timeline of _level0, the following will replace the movie in _level0 if _level1 has not yet been defined:

loadMovie("myMovie.swf", _level1);

The following is a safer approach if you can't guarantee that the level already exists:

loadMovie("myMovie.swf", "_level1");  // Works even if _level1 doesn't exist

However, the existence of _level0 is always guaranteed, so we can always refer to it using _level0 without quotes, as in:

startDrag(_level0, true);

See Also

_global, loadMovie( ), _root, unloadMovie( ); "Importing External Movies," and "Movie and Instance Stacking Order," in Chapter 13



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net