flash display_list_adding_objects
Adding display objects
In ActionScript 3, when a visual object is created it is not automatically added to the display list as it was in ActionScript 1 and 2. The object exists in the memory but not in the display list and is therefore not rendered. In this case the object is called an off list display object. To display it we use one ot two methods defined by the DisplayObjectContainer class called addChild and addChildAt.
Here is the signature of the addChild method:
public function addChild(child:DisplayObject):DisplayObject
The addChild method accepts an instance of DisplayObject as the only parameter. To see our visual object we need to add it to the child object list of a DisplayObjectContainer present in the display list.
We can add for example the instance of our main timeline:
var myTextField:TextField = new TextField(); myTextField.text = "Hello World"; addChild ( myTextField );
We get the display list illustrated by the following diagram:
This new behavior is extremely powerful. All ActionScript developers have at some point wanted to load an image or attach an object to the library without it displaying. With the off list display list concept a visual object can ‘live’ without being displayed. This behavior offers new possibilities to the optimization of display. We will come back to this in the chapter Bitmap development.
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



