PDA

View Full Version : The Display List (AS 3.0)


r3h0ld3r
07-23-2008, 03:54 PM
I recently went out and picked up Learning Actionscript 3.0: A Beginners Guide because I'm absolutely new to AS. I came upon a chapter about "The Display List" in AS 3.0. However I can't understand a bit of the chapter because I've not been able to grasp what exactly the the display list is.

Is there anyway to physically look at the display list or is it something to keep in the back of your head?

Also, if anyone could further explain and possibly give examples of display objects and display object containers?

ANY help is useful. Thanks.

senocular
07-23-2008, 04:23 PM
Have you worked with AS1/AS2 before? Are you familiar with movie clips and how movie clips can contain other movie clips, etc.? That's all the display list is, really. Its a conceptual representation of how visual objects on the screen relate to each other. And really, a more accurate term would be "display tree" since any one movie clip can contain any number (practically) of other movie clips.
See:
http://www.senocular.com/flash/tutorials/as3withflashcs3/images/graphic_dsiplayList.png

The above picture shows a representation of what the display tree might look like if written out as a graph. In Flash this might look like some kind of image viewer or picture frame or something. But the graphics that compose it visually are all on the screen and rendered inside the Flash player for people to see when the movie is played.

The big change from AS2 is that in AS3 you can have movie clip objects exist off screen. And by off screen I don't mean moved to the side in a -x or -y so they can't be seen, I mean like someone going in, reaching in to the flash player, pulling out a movie clip, and sticking it in a bin off to the side that no one can see. This causes the movie clip to become "off-list". In fact, when you make movie clips dynamically with ActionScript, they start off off-list. They're only made visible when you add them to the "active display list", that is you use addChild/addChildAt to actually put them on the screen. The removeChild methods allow you to take them out of the display list so they're no longer visible again.

Why would you want to do this in AS3? For one, it makes movie clips much more portable. You are no longer restricted to the timeline when you create them. This means you can have them on the timeline, have them never on a timeline, or even move them from one timeline to another - this was never possible with AS2.

So in the end, anything that is visible in Flash, is a display object. Anything that can hold another display object is a display object container (makes sense, right). For example, text fields cannot hold other objects, but movie clips can. Textfield is not a display object container, MovieClip is.

That help?

I'm sure you can find other tutorials online that can help explain this further.

r3h0ld3r
07-23-2008, 04:48 PM
I've actually never worked with any AS before so I'm starting off with AS 3.0. Your post was really helpful. Seems like the display list, or tree, is really just a fancy way of putting an easy concept. Thanks, you really cleared things up!