uzu 螺旋をグルグルとアニメーションで描いてみる練習
// forked from enoeno's uzu 螺旋をグルグルと描いてみる練習
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
[SWF(backgroundColor = "0x000000")]
public class FlashTest extends Sprite {
private var container:Sprite;
private var maxPoints:int = 10000;
private var counter:int = 0;
private var timer:Timer;
private var points:Array = new Array();
private var sp:Sprite;
public function FlashTest() {
// write as3 code here..
init();
}
private function init():void{
var pos:Number = 76;
var centerX:Number = stage.stageWidth/2;
var centerY:Number = stage.stageHeight/2;
container = new Sprite();
addChild(container);
for(var i:Number = 0; i < pos*Math.PI; i += (Math.PI/180.0)){
var obj:Object = new Object();
obj.x = (Math.cos(i) + (i * Math.sin(i))) +centerX;
obj.y = (Math.sin(i) + (i * Math.cos(i))) +centerY;
points.push( obj );
}
timer = new Timer(10);
timer.addEventListener(TimerEvent.TIMER, drawSpiral);
timer.start();
}
private function drawSpiral( e:TimerEvent ):void {
sp = new Sprite();
sp.graphics.lineStyle(0, 0x5fef08, 85, false, "none", "round");
sp.blendMode = BlendMode.ADD;
if( counter < points.length ){
sp.graphics.moveTo( points[counter].x, points[counter].y );
if( counter > 0 ) sp.graphics.lineTo( points[counter-1].x, points[counter-1].y );
container.addChild(sp);
counter ++;
} else {
timer.stop();
}
}
}
}