Beginning with the Graphics Class

With ActionScript, you can draw lines, curves, shapes, fills, and gradients. As with most ActionScript features, this ability comes to you courtesy of a class—in this case, the flash.display.Graphics class. Using the Graphics class, you can draw on instances of these three classes: Shape, Sprite, and MovieClip. Each of these classes has a graphics property, which, in turn, provides all the properties and methods of the Graphics class. So, for example, if you want to define how a line looks, you use the graphics.lineStyle() method. It looks like this:

spriteLine.graphics.lineStyle(3,0x00FF00);

Or, if you want to actually draw a line, it looks like this:

spriteLine.graphics.lineTo(20,150);

The important point to notice about the Graphics class is that it's a read-only property of the Shape, Sprite, or MovieClip classes. You reference the Graphics class by referencing one of those classes, then the Graphics class itself, and then the property or method of the Graphics class that you want to use.