package { import flash.display.Sprite; [SWF(backgroundColor="#ffffff", width="500", height="500")] public class MyProgram extends Sprite { public function MyProgram():void { var a:Array = [1, 2, "hello"]; a.sort(); drawCar(40, 40, 200, 100); drawCar(200, 200, 200, 200); } private function drawCar(x:Number, y:Number, width:Number, height:Number):void { // draw red rectangle at (40, 40) with width of 200 and height of 100 graphics.beginFill(0xFF0000); graphics.drawRect(x, y, width, height); graphics.endFill(); // draw two circles with a background color of 0xCCCCCC and // a 2px black outline. the wheels shoulds be lined up along // the bottom edge of the car, 40 pixels in from either side. graphics.beginFill(0xCCCCCC); graphics.lineStyle(2, 0x000000); graphics.drawCircle(x + 40, y + height, 20); graphics.drawCircle(x + width - 40, y + height, 20); graphics.endFill(); // draw the front of the car graphics.moveTo(x + width, y); graphics.lineTo(y + width + 20, y + height); graphics.lineTo(x + width, y + height); graphics.lineStyle(); } } }