package
{
import flash.display.Sprite;
import flash.events.Event;
public class Rotate2 extends Sprite
{
private var ball:Ball;
private var vx:Number=0.05;
public function Rotate2()
{
ball=new Ball;
ball.x=Math.random() * stage.stageWidth;
ball.y=Math.random() * stage.stageHeight;
this.addChild(ball);
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
var x1:Number=ball.x - stage.stageWidth / 2;
var y1:Number=ball.y - stage.stageHeight / 2;
//这是一个绕圆点的计算公式
///vx可以调节速度
//这个其实就是math.cos(angle)*randi 的拆分出来的
//中间的j加减号可以调节方向
var x2:Number=Math.cos(vx) * x1 + Math.sin(vx) * y1;
var y2:Number=Math.cos(vx) * y1 - Math.sin(vx) * x1;
ball.x=stage.stageWidth / 2 + x2;
ball.y=stage.stageHeight / 2 + y2;
}
}
}