User Guide
190 Display Programming
The GeometricSprite class and its subclasses
Each display object the user can add to the canvas is an instance of one of the following
subclasses of the GeometricSprite class:
■ CircleSprite
■ SquareSprite
■ Tr i a n g l e S p r i t e
The GeometricSprite class extends the flash.display.Sprite class:
public class GeometricSprite extends Sprite
The GeometricSprite class includes a number of properties common to all GeometricSprite
objects. These are set in the constructor function based on parameters passed to the function.
For example:
this.size = size;
this.lineColor = lColor;
this.fillColor = fColor;
The geometricShape property of the GeometricSprite class defines an IGeometricShape
interface, which defines the mathematical properties, but not the visual properties, of the
shape. The classes that implement the IGeometricShape interface are defined in the example
application for Chapter 4 (see “Example: GeometricShapes” on page 148).
The GeometricSprite class defines the
drawShape() method, which is further refined in the
override definitions in each subclass of GeometricSprite. For more information, see the
“Adding display objects to the canvas” section, which follows.
The GeometricSprite class also provides the following methods:
■ The onMouseDown() and onMouseUp() methods, which are described in “Clicking and
dragging display objects” on page 192.
■ The showSelected() and hideSelected() methods, which are described in “Clicking
and dragging display objects” on page 192.