13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Display programming<br />

Advantages of the display list approach<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

In ActionScript 3.0, there are separate classes for differ<strong>en</strong>t types of display objects. In ActionScript 1.0 and 2.0, many<br />

of the same types of objects are all included in one class: the MovieClip class.<br />

This individualization of classes and the hierarchical structure of display lists have the following b<strong>en</strong>efits:<br />

More effici<strong>en</strong>t r<strong>en</strong>dering and reduced memory usage<br />

Improved depth managem<strong>en</strong>t<br />

Full traversal of the display list<br />

Off-list display objects<br />

Easier subclassing of display objects<br />

More effici<strong>en</strong>t r<strong>en</strong>dering and smaller file sizes<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

In ActionScript 1.0 and 2.0, you could draw shapes only in a MovieClip object. In ActionScript 3.0, there are simpler<br />

display object classes in which you can draw shapes. Because these ActionScript 3.0 display object classes do not<br />

include the full set of methods and properties that a MovieClip object includes, they are less taxing on memory and<br />

processor resources.<br />

For example, each MovieClip object includes properties for the timeline of the movie clip, whereas a Shape object does<br />

not. The properties for managing the timeline can use a lot of memory and processor resources. In ActionScript 3.0,<br />

using the Shape object results in better performance. The Shape object has less overhead than the more complex<br />

MovieClip object. Flash Player and AIR do not need to manage unused MovieClip properties, which improves speed<br />

and reduces the memory footprint the object uses.<br />

Improved depth managem<strong>en</strong>t<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

In ActionScript 1.0 and 2.0, depth was managed through a linear depth managem<strong>en</strong>t scheme and methods such as<br />

getNextHighestDepth().<br />

ActionScript 3.0 includes the DisplayObjectContainer class, which has more conv<strong>en</strong>i<strong>en</strong>t methods and properties for<br />

managing the depth of display objects.<br />

In ActionScript 3.0, wh<strong>en</strong> you move a display object to a new position in the child list of a DisplayObjectContainer<br />

instance, the other childr<strong>en</strong> in the display object container are repositioned automatically and assigned appropriate<br />

child index positions in the display object container.<br />

Also, in ActionScript 3.0 it is always possible to discover all of the child objects of any display object container. Every<br />

DisplayObjectContainer instance has a numChildr<strong>en</strong> property, which lists the number of childr<strong>en</strong> in the display object<br />

container. And since the child list of a display object container is always an indexed list, you can examine every object<br />

in the list from index position 0 through the last index position (numChildr<strong>en</strong> - 1). This was not possible with the<br />

methods and properties of a MovieClip object in ActionScript 1.0 and 2.0.<br />

Last updated 6/6/2012<br />

156

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!