In ActionsScript, primitive vectors, lines, and shapes are drawn
via the Graphics class. However,
the Graphics class is never
instantiated directly; instead, each ActionScript class that supports
programmatic vector drawing creates a Graphics instance automatically and provides
access to it via the instance variable
graphics. The display classes that support
vector drawing are Sprite,
MovieClip, and Shape.
Shape objects consume less memory than Sprite and MovieClip objects. Hence, to conserve memory, vector content should be drawn in Shape objects whenever the containment and interactive capabilities of the Sprite and MovieClip classes are not required.
As shown in Table 25-1, the Graphics class's drawing tools can be broken down into five general categories: drawing lines, drawing shapes (also known as fills), defining line styles, moving the drawing pen, and removing graphics.
Table 25-1. Graphics class overview
curveTo( ), lineTo( )
beginBitmapFill( ), beginFill( ), beginGradientFill( ), drawCircle( ), drawEllipse( ), drawRect( ), drawRoundRect( ), drawRoundRectComplex( ), endFill( )
Defining line styles
lineGradientStyle( ), lineStyle( )
Moving the drawing pen
Conceptually, lines and curves are drawn in ActionScript by a theoretical "drawing pen." For all new Sprite, MovieClip, and Shape objects, the pen starts out at position (0,0). As lines ...