/ Published in: ActionScript 3
Copy&paste into new document and move your mouse.
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>(); Â // populate vectors 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.x = circleSegment.y = 200; addChild(circleSegment); Â addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { Â Â with (circleSegment.graphics) { Â Â Â Â clear(); Â Â Â Â beginFill(0x000000); Â Â Â Â Â Â Â Â // count by two, up to coords.length (drawCommands is exactly half the length of coords) Â Â Â Â maxIndex = Â Math.ceil((mouseX / stage.stageWidth) Â * drawCommands.length) * 2; Â Â Â Â Â drawPath(drawCommands, coords.slice(0, maxIndex)); Â Â } }
Comments
Subscribe to comments
You need to login to post a comment.

Here is some mod to make it use Tweener:
Comment:
/*addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { with (circleSegment.graphics) { clear(); beginFill(0x000000);
}*/
and add:
import caurina.transitions.Tweener;
var numProxy:Object = {}; numProxy.numValue = 0
Tweener.addTween(numProxy, {numValue:100, time:6, onUpdate:draww, transition:"easeInQuad"})
function draww(e:Event = null):void{ with (circleSegment.graphics) { clear(); beginFill(0x000000);
}