ActionScript 3: The Display List
Mar 12th, 2008 by Leo A. Geis
The AS3 Display List is perhaps the most difficult adaptation for AS2 programmers. Understanding the “strategy” behind the Display List helps make everything else seem obvious.
The Display List is nothing more than the collection of Objects that are rendered (displayed) at a particular time (Frame) in a published .swf. If an Object is not in the Display List at a point in time, it is not rendered on the Stage-and therefore not visible.
One underlying strategy is that an unrendered Object is not taxing the render engine when not included in the Display List, thus processor and memory employment are reduced. “Off-List” Display Objects may certainly be created, but even then their resource exploitation is minimized.
The practitioner does not have access to a formalized textual list of Objects on the Display List within the API, excepting one produced by Tracing out all Objects so qualified:
An Object is not added to the Display List until the addChild() or addChildAt() Methods of a DisplayObjectContainer Instance that is already on the Display List is called. The DisplayObject Class-as distinguished from the DisplayObjectContainer Class-does not offer the addChild() or addChildAt() Methods:
The Stage, inheriting from DisplayObjectContainer, does:
The flash.display Package contains all of the Classes for use in the Display List:
The Stage is the root of the Display List hierarchy. The Stage does not have a Timeline and has no Events, Methods or Properties directly related to controlling a Timeline or Timeline activity (aside from the frameRate Property, which may also be specified in the IDE’s Property Inspector Panel Frame Rate Field). The Stage is nothing more than a spatial and administrative container for all Display Objects.
The Main Timeline is the root of the application, and it is Instantiated by adding a Custom Class (via addChild() or addChildAt()) that extends either Sprite or MovieClip to the Stage.
This Custom Class extending Sprite or MovieClip is called the “Document Class” and may also (in addition to the API) be specified in the IDE’s Property Inspector Panel “Document Class” Field or in the Publish Settings>Flash>ActionScript version>Settings Dialogue Box. Obviously the Document Class must be in the document’s Classpath.
The Flash Player automatically creates the Stage Instance, adds it to the Display List, Instantiates the .swf’s Document Class (by calling its Constructor) and adds it to the Display List as the Stage’s first Child at Runtime.
Consider the Document Class as your application, not as a type of Class or as a strict functional subordinate of the Stage.
Although the Stage Class is a member of the flash.display Package (it inherits from DisplayObjectContainer) it is not globally accessible and must be addressed through the stage Property of a DisplayObject Instance (the stage Property of a DisplayObjectContainer reverts to the stage Property of its DisplayObject Child).
Objects are removed from the Display List via the removeChild() and removeChildAt() Methods of the parent DisplayObjectContainer.
L






