Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 188

Programming actionscript 3.0
Table of Contents

Advertisement

File
com/example/programmingas3/
geometricshapes/EquilateralTriangle.as
com/example/programmingas3/
geometricshapes/Square.as
com/example/programmingas3/
geometricshapes/
GeometricShapeFactory.as
Defining the SpriteArranger classes
The SpriteArranger application lets the user add a variety of display objects to the onscreen
"canvas."
The DrawingCanvas class defines a drawing area, a type of display object container, to which
the user can add onscreen shapes. These onscreen shapes are instances of one of the subclasses
of the GeometricSprite class.
The DrawingCanvas class
In Flex, all child display objects added to a Container object must be of a class that descends
from the mx.core.UIComponent class. This application adds an instance of the
DrawingCanvas class as a child of an mx.containers.VBox object, as defined in MXML code
in the SpriteArranger.mxml file. This inheritance is defined in the DrawingCanvas class
declaration, as follows:
public class DrawingCanvas extends UIComponent
The UIComponent class inherits from the DisplayObject, DisplayObjectContainer, and
Sprite classes, and the code in the DrawingCanvas class uses methods and properties of those
classes.
The
DrawingCanvas()
property that is later used in drawing the outline of the canvas. It then calls the
method, as follows:
this.bounds = new Rectangle(0, 0, w, h);
initCanvas(fillColor, lineColor);
188
Display Programming
Description
A subclass of RegularPolygon that defines a triangle
with all sides the same length.
A subclass of RegularPolygon defining a rectangle
with all four sides the same length.
A class containing a "factory method" for creating
shapes given a shape type and size.
constructor method sets up a Rectangle object,
, which is
bounds
initCanvas()

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents