/ Published in: ActionScript 3
URL: http://snipplr.com/view.php?codeview&id=45022
Credit goes to http://snipplr.com/users/MaRmAR/
Expand |
Embed | Plain Text
[SWF(width=400,height=400,backgroundColor=0xEFEFEF,frameRate=30)] const TWO_PI:Number = Math.PI * 2; var resolution:Number = 50; var step:Number = TWO_PI / resolution; var maxIndex:int = 0; var coords:Vector.<Number> = new Vector.<Number>(); var drawCommands:Vector.<int> = new Vector.<int>(); for (var i:Number = 0; i <TWO_PI + step; i += step){ coords.push(100 * Math.cos(i)); coords.push(100 * Math.sin(i)); drawCommands.push(GraphicsPathCommand.LINE_TO); } var circleSegment:Shape = new Shape(); circleSegment.rotation = -90; circleSegment.x = circleSegment.y = 200; addChild(circleSegment); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { with (circleSegment.graphics) { clear(); beginFill(0x000000); maxIndex = Math.ceil((mouseX / stage.stageWidth) * drawCommands.length) * 2; drawPath(drawCommands, coords.slice(0, maxIndex)); } }
You need to login to post a comment.
