Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 166

Programming actionscript 3.0
Table of Contents

Advertisement

You can use off-list display objects to assemble complex display objects, such as those that
have multiple display object containers containing multiple display objects. By keeping
display objects off-list, you can assemble complicated objects without using the processing
time to render these display objects. You can then add an off-list display object to the display
list when it is needed. Also, you can move a child of a display object container on and off the
display list and to any desired position in the display list at will.
Easier subclassing of display objects
In ActionScript 1.0 and 2.0, you would often have to add new MovieClip objects to a SWF
file to create basic shapes or to display bitmaps. In ActionScript 3.0, the DisplayObject class
includes many built-in subclasses, including Shape and Bitmap. Because the classes in
ActionScript 3.0 are more specialized for specific types of objects, it is easier to create basic
subclasses of the built-in classes.
For example, in order to draw a circle in ActionScript 2.0, you could create a CustomCircle
class that extends the MovieClip class when an object of the custom class is instantiated.
However, that class would also include a number of properties and methods from the
MovieClip class (such as
however, you can create a CustomCircle class that extends the Shape object, and as such does
not include the unrelated properties and methods that are contained in the MovieClip class.
The following code shows an example of a CustomCircle class:
import flash.display.*;
private class CustomCircle extends Shape
{
var xPos:Number;
var yPos:Number;
var radius:Number;
var color:uint;
public function CustomCircle(xInput:Number,
{
xPos = xInput;
yPos = yInput;
radius = rInput;
color = colorInput;
this.graphics.beginFill(color);
this.graphics.drawCircle(xPos, yPos, radius);
}
}
166
Display Programming
) that do not apply to the class. In ActionScript 3.0,
totalFrames
yInput:Number,
rInput:Number,
colorInput:uint)

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents