flash display_list_levels

_level

In ActionScript 3 the notion of _level is no longer available. You will remember that in ActionScript 1 and 2 we could write:

_level0.createTextField ( "myTextField", 0, 0, 0, 150, 25 );

This code creates a textfield in _level0. In ActionScript 3 if we try to access the _level object we get a compilation error:

var myTextField:TextField = new TextField();
myTextField.text = "Hello!”;
_level0.addChild ( myTextField );

This displays the following in the output panel:

1120: Access to the property not defined _level0.

There is no similar object to _level in ActionScript 3 that we know of. We can however easily achieve the same result in ActionScript 3. By adding our graphic objects to the Stage object rather to our timeline we get the same result:

var myTextField:TextField = new TextField();
myTextField.text = "Hello!”;
stage.addChild ( myTextField );

The previous code defines the display list illustrated here:

4.16.jpg

Our textfield here is a direct child of the Stage object, we therefore get the same idea of stacking the timeline established by _levels. In this situation the Stage object contains two direct children.

var myTextField:TextField = new TextField();
myTextField.text = "Hello!”;
stage.addChild ( myTextField );
// displays : 2
trace ( stage.numChildren );

Even if this technique allows us to simulate the idea of _level in ActionScript 3, its use is not recommended apart from in very specific cases, for example an alert window which should be displayed above all the elements of our application.

Worth remembering

  • In ActionScript 3, the idea of _level no longer exists.







Adobe Training center


Mediabox Training Centre © 2000 - 2008 All rights reserved.
Adobe Authorized Training Centre. State convention under number 25 14 02167 14.
Mediabox : SARL au capital de 62.000€ - Activity number: 25 14 02167 14 - SIRET : 493 716 468 00027
MEDIABOX, 102 Avenue des Champs Elysées, 75008 PARIS - Tel. +33(0)2.31.91.96.89 - Fax. +33(0)2.72.68.56.42