User Guide
Example: SpriteArranger 189
AS the following example shows, the initCanvas() method defines various properties of the
DrawingCanvas object, which were passed as arguments to the constructor function:
this.lineColor = lineColor;
this.fillColor = fillColor;
this.width = 500;
this.height = 200;
The initCanvas() method then calls the drawBounds() method, which draws the canvas
using the DrawingCanvas class’s
graphics property. The graphics property is inherited
from the Shape class.
this.graphics.clear();
this.graphics.lineStyle(1.0, this.lineColor, 1.0);
this.graphics.beginFill(this.fillColor, 1.0);
this.graphics.drawRect(bounds.left - 1,
bounds.top - 1,
bounds.width + 2,
bounds.height + 2);
this.graphics.endFill();
The following additional methods of the DrawingCanvas class are invoked based on user
interactions with the application:
■ The addShape() and describeChildren() methods, which are described in “Adding
display objects to the canvas” on page 191.
■ The moveToBack(), moveDown(), moveToFront(), and moveUp() methods, which are
described in “Rearranging display object layering” on page 194.
■ The onMouseUp() method, which is described in “Clicking and dragging display objects”
on page 192.