package { import flash.display.Sprite; public class Truck extends Sprite { public var vx:Number; public var vy:Number; public function Truck(width:Number, height:Number):void { vx = 0; vy = 0; // draw red rectangle at (40, 40) with width of 200 and height of 100 graphics.beginFill(0xFF0000); graphics.drawRect(0, 0, 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(40, height, 20); graphics.drawCircle(width - 40, height, 20); graphics.endFill(); // draw the front of the car graphics.moveTo(width, 0); graphics.lineTo(width + 20, height); graphics.lineTo(width, height); graphics.lineStyle(); } public function update():void { x += vx; y += vy; } } }