Working With The Display List In Flash ActionScript 3

by Andrew Whiteman on August 8, 2009

by Andrew Whiteman

Adobe Flash ActionScript 3 has dramatically altered and improved the way in which visual elements are added to a project. In fact, in ActionScript 2, visual elements were not even recognized as all belonging to the same group: different syntax was required to handle each different type of visual element. ActionScript 3 rationalises the whole business of maniuplating visual assets by introducing a new, very flexible and very powerful concept: the display list.

Put simply, the display list is a built-in inventory of every visual element residing in an application and, like the DOM (document object model) found in JavaScript, it has a hierarchical structure. It contains a variety of disparate elements such as movie clips, sprites (simple movie clips), vector shapes, bitmaps and video.

One significant distinction that should be made between the various elements in the display list is the one between display objects containers and display objects. Objects such as movie clips are treated as display object containers since they are capable of containing other display objects. Objects such as vector Shapes, bitmaps and video (which cannot contain other objects), are treated as display objects plain and simple.

ActionScript 3 features a rich body of syntax for manipulating the display list: display objects can be easily added and removed and there are a number of different ways of targeting objects within the display list hierarchy.

The Stage is the object residing at the top of the display list hierarchy since it contains the entire Flash movie. Next, as we drill down through the hierarchy, we have the main timeline of the movie; and then we have all the various types of visual objects, divided into containers and objects. The main classes of display object containers are movie clips, sprites and loaders.

Movie clips have been around in Flash forever; they are a bit like clones of the main movie, each movie clip having its own timeline. Sprites are a new to ActionScript 3: they are basically movie clips without a timeline into which other objects can be placed. Their relative simplicity makes them ideal candidates for ActionScript animation. The loader class, also new to ActionScript 3, is used specifically as a container into which external assets such as bitmaps and SWF files can be loaded.

Turning to objects which cannot act as containers, Shapes are vector objects usually created using the drawing tools within Flash. There is also a new class of object referred to as an Interactive Object. This category includes simple buttons with an over, up and down state as well as text fields. As with previous versions of Flash, there are dynamic text fields whose output can be manipulated with ActionScript as well as input text fields, which can also accept keyboard input from the user.

About the Author:

Technorati Tags: , , , , , , , ,

Leave a Comment

Previous post:

Next post: