flash display_list_graphic_classes
Graphic classes
As we have seen, all of the graphic classes in ActionScript 3 are stored in specific places and reside in three packages: flash.display, flash.media and flash.text.
The following diagram regroups the ensemble:
We can see with this diagram the multitude of visual classes available for an ActionScript 3 developer. But we can also ask: why have so many classes?
ActionScript 3 was developed with an optimization problem. By offering a large choice of visual classes we have the possibility of using the most optimized object for each need. The more a visual class is enriched the more memory it takes up. Because of the small amount of visual classes in ActionScript 1 and 2, lots of developers used the MovieClip class to do all of their work which was not very optimized.
In ActionScript 1 and 2 only 4 visual classes exist: MovieClip, Button, TextField and finally BitmapData.
Let’s take the example of a traditional Flash as a drawing application. Before ActionScript 3 the only object that allowed us to draw using the API was the MovieClip class. This integrates a timeline as well as methods related to the handling of the player head which were useless for us in this precise case. A simple lighter Shape object was sufficient to draw. Following this same idea we prefer to use a SimpleButton object more than a MovieClip for the creation of buttons.
We have to memorise three types of visual objects.
- The object types: flash.display.DisplayObject
Any element needing to be displayed should be of the Displayobject type. A textfield, button or a clip will therefore be a DisplayObject. Throughout your ActionScript 3 developments you would generally describe any object that can be posted as a DisplayObject. The DisplayObject class defines all the basic properties related to display, position, rotation, stretching and other more advanced properties. //Beware, an object inheriting a DisplayObject like Shape has no capacity to contain visual objects. Amongst the direct DisplayObject sub-classes we can quote the following classes Shape, Video and Bitmap.
- The object types flash.display.InteractiveObject
The InteractiveObject class defines the behavior linked to the interactivity. When an object inherits the InteractiveObject class it can react to other user entries triggered by the mouse or the keyboard. Amongst the visual objects coming directly from the InteractiveObject class we have the SimpleButton and TextField classes.
- The object types flash.display.DisplayObjectContainer
Unlike DisplayObjects, DisplayObjectContainers can contain visual objects. We will now discuss the child object to qualify a visual object in another. The objects inheriting this class are therefore called DisplayObjectContainers. The DisplayObjectContainer is a sub-class of the DisplayObject class and defines all the properties and methods and defines all properties and methods relative to the manipulation of child objects. Loader, Sprite and Stage directly inherit the DisplayObjectContainer.
Throughout our ActionScript 3 developments, certain visual objects cannot be instanced while others can. We can separate the ensemble of visual classes into two categories:
Instantiable objects:
- flash.display.Bitmap: this class acts as a wrapper to the flash.display.BitmapData object which cannot be added to the display list without a Bitmap wrapper.
- flash.display.Shape: this is a basic class for all vectorial content, it is strongly linked to the drawing API thanks to its graphics property. We will soon come back to the drawing API.
- flash.media.Video: the Video class works to display video flux coming from a webcam, streaming server or simple video (FLV, MP4, MOV, etc.).
- flash.text.TextField: text management is achieved by the TextField class.
- flash.display.SimpleButton: the SimpleButton class allows you to dynamically create buttons which was impossible in previous versions of ActionScript.
- flash.display.Loader: the Loader class manages the loading of all external visual content, loading of SWFs and images (PNG, GIF, JPG).
- flash.display.Sprite: the Sprite class is a lightened MovieClip as it has no timeline.
- flash.display.MovieClip: the MovieClip class is the most enriched visual class. It is linked to traditional animation.
Non-instanceable objects:
- flash.display.AVM1Movie: when an ActionScript 1
or 2 animation is loaded in a ActionScript 3 animation, the Flash 9 player wraps the old-type animation in an AVM1Movie object type, it is therefore imposible to instantiate an object of this type through development.
- flash.display.InteractiveObject: the
InteractiveObject class defines the behavior linked to the interactivity like mouse or keyboard events.
- flash.display.MorphShape: the interpolated shapes are represented by the MorphShape object. Only the Flash CS3 author environment can create objects of this type.
- flash.display.StaticText: the StaticText class represents the static textfields created in the Flash CS author environment.
- flash.display.Stage: this is the main container of our visual content.
Worth remembering
- You should use the most optimized class in each case
- Visual classes reside in three different packages: flash.display, flash.media, and flash.text
- The DisplayObject, InteractiveObject, and DisplayObjectContainer classes are abstract and can’t be instantiated or inherited in ActionScript.
Mediabox Training Centre © 2000 - 2008 All rights reserved.
Adobe Authorized Training Centre. State convention under number 25 14 02167 14.
Mediabox : SARL au capital de 62.000€ - Activity number: 25 14 02167 14 - SIRET : 493 716 468 00027
MEDIABOX, 102 Avenue des Champs Elysées, 75008 PARIS - Tel. +33(0)2.31.91.96.89 - Fax. +33(0)2.72.68.56.42



