源码
以下是源代码:
<!--l version="1.0" encoding="utf-8-->
<![CDATA[
import mx.core.UIComponent;
var cirlce:UIComponent = new UIComponent();
var line:UIComponent = new UIComponent();
var x1:Number=new Number;
var y1:Number=new Number;
var second:Number = new Number;
var ticker:Timer;
private function init():void{
this.addChild(cirlce);
x1 = 350;
y1 = 230;
second = 1;
cirlce.graphics.beginFill(0x0099ff);
cirlce.graphics.lineStyle(1,0x0099ff,1);
cirlce.graphics.drawCircle(350,130,100);
cirlce.graphics.endFill();
this.addChild(line);
line.graphics.moveTo(350,130);
line.graphics.lineStyle(1,0xcccccc);
line.graphics.lineTo(x1,y1);
ticker = new Timer(1000);
ticker.addEventListener(TimerEvent.TIMER,oneSecond);
ticker.start();
}
private function oneSecond(event:TimerEvent):void
{
if(second>60)
second = 1;
if(second>0&&second<31)
{
if(second<=15)
{
x1 = 350-Math.sin(6*second*Math.PI/180)*100;
y1 = 130+Math.cos(6*second*Math.PI/180)*100;
}
else
{
x1 = 350-Math.cos(6*(second-15)*Math.PI/180)*100;
y1 = 130-Math.sin(6*(second-15)*Math.PI/180)*100;
}
}
else
{
if(second<=45)
{
x1 = 350+Math.sin(6*(second-30)*Math.PI/180)*100;
y1 = 130-Math.cos(6*(second-30)*Math.PI/180)*100;
}
else
{
x1 = 350+Math.cos(6*(second-45)*Math.PI/180)*100;
y1 = 130+Math.sin(6*(second-45)*Math.PI/180)*100;
}
}
line.graphics.clear();
line.graphics.moveTo(350,130);
line.graphics.lineStyle(1,0xcccccc);
line.graphics.lineTo(x1,y1);
second++;
}
]]>