1.先做一个蜻蜒的元件(movie) 记得翅膀要会动哦。哈哈
2。将元件拉入场景中。然后命名为qt. 选中qt,按F9键入如下代码:
onClipEvent (enterFrame) {
if (i == 360) {
i = 1;
}
setProperty(this, _rotation, i+=5);
/* if(_x>=Stage.width) {_x=1;}
setProperty(this, _x, _x+=random(10));
if(_y>=Stage.height) {_y=1;}
setProperty(this, _y, _y+=random(3));
*/
if (xflag) {
setProperty(this,_x,_x+=random(16));
if (_x>=Stage.width) { xflag=false; }
} else {
setProperty(this,_x,_x-=random(8));
if (_x<=0) { xflag=true; }
}
if (yflag) {
setProperty(this,_y,_y+=random(3));
if (_y>=Stage.height) { yflag=false; }
} else {
setProperty(this,_y,_y-=random(9));
if (_y<=0) { yflag=true; }
}
//trace(_x+","+_y)
}
onClipEvent (load) {
var i = random(360);
var xflag = true;
var yflag = true;
}
然后Ctrl+ENTER吧