/*Note, in order to compile with MTASC, you need to download the Delegate Class from http://dynamicflash.com/classes/Delegate.as and put it in an std/mx/utils directory. See http://dynamicflash.com/2005/05/delegate-version-101/ for more info */ import mx.utils.Delegate; import flash.geom.*; class Wheel { public var scope: MovieClip; public var p1: Point; public var p2: Point; public var THETA: Number; public var ORIGIN: Point; public var count: Number; public var mat: Matrix; function Wheel(tgt:MovieClip) { scope = tgt.createEmptyMovieClip("main", tgt.getNextHighestDepth()); ORIGIN = new Point(0,0); THETA = 2 * Math.PI / 360; //360 degrees p1 = new Point(40,0); p2 = new Point(100,0); count = 360; //initial angle used for drawing mat = new Matrix(Math.cos(THETA), -Math.sin(THETA), Math.sin(THETA), Math.cos(THETA), 0, 0); while(count){ scope.lineStyle(2, count * 0xCC); //assign color to line based on count scope.moveTo(ORIGIN.x + p1.x, ORIGIN.y + p1.y); scope.lineTo(ORIGIN.x + p2.x, ORIGIN.y + p2.y); p1 = mat.transformPoint(p1); p2 = mat.transformPoint(p2); count--; } //reposition object for viewing this.scope._x = 50; this.scope._y = 120; //assign event handler scope.onEnterFrame = Delegate.create(this, handleEnterFrame); } public function handleEnterFrame(){ this.scope._rotation += 1; if(this.scope._rotation == 360){ this.scope._rotation = 0; } } // --- Main Entry Point static function main() { var wheel:Wheel = new Wheel(_root); } }