package {
import flash.display.movieclip;
import flash.events.event;
public class main extends movieclip {
public function main() {
}
public function hs(_mc:movieclip) {
var dx:int=10;
var dy:int=10;
var jiaodu:number=math.random()*(2*math.pi);
_mc.addeventlistener(flash.events.event.enter_frame,enter_f);
function enter_f(e:event) {
e.target.x+=math.cos(jiaodu)*dx;
e.target.y+=math.sin(jiaodu)*dy;
if (e.target.x+e.target.width>stage.stagewidth) {
dx*=-1;
e.target.x-=10;
}
if (e.target.x<0) {
dx*=-1;
e.target.x+=10;
}
if (e.target.y+e.target.height>stage.stageheight) {
dy*=-1;
e.target.y-=10;
}
if (e.target.y<0) {
dy*=-1;
e.target.y+=10;
}
}
}
}
}
//
var _mc:mc;
for(var i:uint;i<10;i++){
_mc=new mc();
_mc.x=stage.stagewidth*math.random();
_mc.y=stage.stageheight*math.random();
addchild(_mc);
hs(_mc);
}
聯(lián)系客服