package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
[SWF(width = "600",height = "600",backgroundColor = "#ffffff",frameRate = "30")]
public class TestAs extends Sprite
{
private var round:Sprite = new Sprite;
private var start:TextField = new TextField;
private var cancle:TextField = new TextField;
private var pause:TextField = new TextField;
private var t:Number = 0;
private var r:int = 100;
public function TestAs()
{
round.graphics.beginFill(0xFF00000);
round.graphics.drawCircle(150,300,20);
addChild(round);
start.text = "start";
start.x = 490;
start.y = 570;
start.addEventListener(MouseEvent.CLICK,startFun);
addChild(start);
cancle.text = "cancle";
cancle.x = 530;
cancle.y = 570;
cancle.addEventListener(MouseEvent.CLICK,cancleFun);
addChild(cancle);
pause.text = "pause";
pause.x = 570;
pause.y = 570;
pause.addEventListener(MouseEvent.CLICK,pauseFun);
addChild(pause);
}
private function startFun(event:MouseEvent):void
{
round.addEventListener(Event.ENTER_FRAME,move);
}
private function cancleFun(event:MouseEvent):void
{
round.removeEventListener(Event.ENTER_FRAME,move);
t = 0;
round.x = 0;
round.y = 0;
}
private function pauseFun(event:MouseEvent):void
{
round.removeEventListener(Event.ENTER_FRAME,move);
}
private function move(event:Event):void
{
round.x = (r - r * Math.cos(t++ * Math.PI / 180));
round.y = (r * Math.sin(t++ * Math.PI / 180));
}
}
}