View comments | RSS feed

_level property

_levelN

A reference to the root Timeline of _levelN. You must use loadMovieNum() to load SWF files into the Flash Player before you use the _level property to target them. You can also use _levelN to target a loaded SWF file at the level assigned by N.

The initial SWF file loaded into an instance of the Flash Player is automatically loaded into _level0. The SWF file in _level0 sets the frame rate, background color, and frame size for all subsequently loaded SWF files. SWF files are then stacked in higher-numbered levels above the SWF file in _level0.

You must assign a level to each SWF file that you load into the Flash Player using loadMovieNum(). You can assign levels in any order. If you assign a level that already contains a SWF file (including _level0), the SWF file at that level is unloaded and replaced by the new SWF file.

Availability: ActionScript 1.0; Flash Player 4

Example

The following example stops the playhead in the main Timeline of the SWF file sub.swf that is loaded into _level9. The sub.swf file contains animation and is in the same directory as the document that contains the following ActionScript:

loadMovieNum("sub.swf", 9);
myBtn_btn.onRelease = function() {
 _level9.stop();
};

You could replace _level9.stop() in the previous example with the following code:

_level9.gotoAndStop(5);

This action sends the playhead in the main Timeline of the SWF file in _level9 to Frame 5 instead of stopping the playhead.

See also

loadMovie function, swapDepths (MovieClip.swapDepths method)


Version 8

Comments


Jackie_2004 said on Apr 8, 2006 at 4:06 PM :
I was working with _levels and realized that if a loaded movie has a sound attached or plays a sound, it doesnt stop if i use stopAllSounds() or _levelN.stopAllSounds(); can someone suggest something??
JohnKirk said on Jul 27, 2006 at 12:05 PM :
Hi,

In order to utilize good programming practices, we need better documentation of the "_level" property, as follows:

1) We know it is possible to create and use a String to be used as the level property:
Example:
function Get_Level_No():Number { return 20; };
function Get_Level_AsStr():String {
return "_level" + Get_Level_No();
};
MCL.unloadClip(Get_Level_AsStr()); (works):

2) It is NOT possible to reference _level properties using this method, and this needs to be documented:
Example:
_level20.XML0 = myXml; (works):
Get_Level_AsStr().XML0 = myXml; (does not work):

Regards,
-- John Kirkish
juankpro said on Aug 1, 2007 at 9:59 AM :
This happens because only the global functions (loadMovie, unloadMovie, duplicateMovieClip, etc) can receive an string, this function later (inside the function definition) gets a reference to the movie and works with it.

It is not that the function can receive a MovieClip reference also. What happens is that the toString function is called in the movie clip prior to passing the parameter and the with that string it references the movie clip in the process. (This is why you should be carefull to pass an existent movie clip other wise the toString will return an empty string (FP 6 and older) and an empty string means the _root movie)

But when you need to call a movie clip directly you cannot use a string, because a string is a string and a movie clip is not a string. For the code to work in the second usage, change the line Get_Level_AsStr().XML0 = myXml; (does not work), to:

eval(Get_Level_AsStr()).XML0 = myXml; // does work

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001788.html