Simple Circle anim
Simple circle anim for a loader
/**
* Copyright IPFix ( http://wonderfl.net/user/IPFix )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qv7D
*/
// forked from 883108's Sin and Cosin Wave
package {
import flash.display.AVM1Movie;
import flash.display.Sprite;
import flash.events.Event;
public class Circle extends Sprite {
private var angle:Number = Math.PI;
private var centerX:Number = stage.stageWidth/2;
private var centerY:Number = stage.stageHeight/2;
private var radius:Number = 50;
private var speed:Number = -Math.PI*2/100;
private var circleMask:Sprite;
public function Circle():void {
var circlePerfect:Sprite = new Sprite();
circlePerfect.graphics.beginFill(0xFAFAFA);
circlePerfect.graphics.lineStyle(3, 0xCCCCCC);
circlePerfect.graphics.drawCircle(centerX,centerY,radius-3);
circlePerfect.graphics.endFill();
addChild(circlePerfect);
circleMask = new Sprite();
circleMask.graphics.beginFill(0xFAFAFA);
circleMask.graphics.lineStyle(3, 0xCCCCCC);
circleMask.graphics.moveTo(centerX,centerY);
addChild(circleMask);
circlePerfect.mask = circleMask;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void{
circleMask.graphics.lineTo(centerX + Math.sin(angle) * radius, centerY + Math.cos(angle) * radius);
if(angle<-Math.PI){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
angle += speed;
}
}
}