package {
import flash.display.Sprite;
import flash.display.Shape;
public class Main extends Sprite {
public function Main( ) {
var red:Circle = new Circle( 0xFF0000, 10 );
red.x = 10;
red.y = 20;
var green:Circle = new Circle( 0x00FF00, 10 );
green.x = 15;
green.y = 25;
var blue:Circle = new Circle( 0x0000FF, 10 );
blue.x = 20;
blue.y = 20;
addChild( red );
addChild( green );
addChild( blue );
}
}
}
class Circle extends flash.display.Shape {
private var _color:uint;
private var _radius:Number;
public function Circle( color:uint = 0x000000, radius:Number = 10 ) {
_color = color;
_radius = radius;
draw( );
}
private function draw( ):void {
graphics.beginFill( _color );
graphics.drawCircle( 0, 0, _radius );
graphics.endFill( );
}
}
|