雨滴.swf
主代码:
package {
import flash.display.Sprite;
import flash.events.Event;
public class xuanzuandezhixian extends Sprite {
//申明变量
private var j:uint;
private var dian:Sprite;
private var r:Sprite;
public function xuanzuandezhixian() {
//画半径
r=new Sprite ;
r.graphics.lineStyle(2,0xFF0000);
r.graphics.moveTo(0,0);
r.graphics.lineTo(50,0);
addChild(r);
r.x=275;
r.y=200;
//添加ENTER_FRAME侦听事件
addEventListener(Event.ENTER_FRAME,gx);
}
private function gx(event:Event):void {
//画小圆
dian=new Sprite ;
dian.graphics.beginFill(0x009900);
dian.graphics.drawCircle(0,0,1);
dian.graphics.endFill();
addChild(dian);
j++;
//设置小圆的坐标随i而变化(即绕圆周运动)
dian.x=Math.cos(j / 180 * Math.PI) * 50 + 275;
dian.y=Math.sin(j / 180 * Math.PI) * 50 + 200;
//半径旋转
r.rotation=j;
//一周后移除ENTER_FRAME侦听事件
if (j >= 360) {
removeEventListener(Event.ENTER_FRAME,gx);
}
}
}
} |