ActionScript 3.0 Display Lists and Display Objects  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Actionscript
Written by Tibor Gyorgy Ballai   
Thursday, 29 March 2007

One of the biggest changes in ActionScript 3.0 is the way Flash renders (or rather manages rendering of) visual assets. Previously, you'd had to attachMovie() from the library, createEmptyMovieClip() or createTextField(). But all of these were methods of existing movie clips.



So if you wanted to create a new visual asset, you had to start with a defined movie clip and that asset would be bound to that clip until it was destroyed. It would also automatically be added to the rendering engine.

If you wanted to create a new MovieClip on the root and then drag and drop it into another MovieClip (say a window that you could drag around), you'd have to remove the MovieClip from its origin and recreate it in the target.

On top of this, there was the issue of depth management. MovieClip.getNextHighestDepth() helped depth management, but if you were using v2 components, getNextHighestDepth() often conflicted, creating headaches that I'm not going to rehash here.

Thankfully, the way Flash handles rendering in ActionScript 3.0 addresses all of these issues. It now uses what's called a Display List and DisplayObjects. The root of any ActionScript 3.0 application is a DisplayObjectContainer, and within that DisplayObjectContainer, you can add DisplayObjects or other DisplayObjectContainers (something that can contain child DisplayObjects).

At the same time, you can create DisplayObjects that exist as data objects but are not necessarily added to the Display List and therefore are not even considered by the rendering engine. This means if you have something like a slide show, you may have 100 Bitmap DisplayObjects, but are only showing one or two at a time, saving resources as the rendering engine only has to consider the objects currently in the Display List.

Also, at any point, you can re-parent (change the scope of a DisplayObject) by adding it as a child of another DisplayObjectContainer. Best of all, the Display List pretty much makes depth management a thing of the past.

So, that was a lot of words. What does it mean in practice? Well, we still have a stage, and the stage is still the root of the display hierarchy. You can refer to the stage from any DisplayObject by referencing it's “stage” (lowercase 's'') property.

DisplayObjects can be things that contain no child DisplayObjects (such as a Bitmap, a Shape, Static Text, Video and a MorphShape). This means that if you need nothing but to display a Bitmap or a simple vector shape, you don't have to create a MovieClip (and all the resources a MovieClip requires) just to display a graphic.

But DisplayObjects can also be Interactive Objects like SimpleButtons TextFields and DisplayObjectContainers. Among DisplayObjectContainers are the objects that can contain child DisplayObjects such as Loader, Sprite and Stage. On the bottom of the hierachy is the resource heavy, but familiar MovieClip.

The chain of inheritance among DisplayObjects looks like this:

Read more


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Thursday, 03 January 2008 )
 
< Prev   Next >