用flash随机函数做气泡上升并且渐变消失,求高手指教,求函数格式!

像图片里这种,从一个点发出气泡 然后慢慢随机飘上去 最后消失
2025-12-07 05:47:24
推荐回答(1个)
回答1:

package {
import flash.display.MovieClip;
import flash.events.*;
public class H2O extends MovieClip {
var speedx:Number=0;
var speedy:Number=0;
public function H2O() {
speedx=0.5*Math.random()-0.5;
speedy=5*Math.random();
this.addEventListener(Event.ENTER_FRAME,MOVE);
}
function MOVE(e:Event):void {
this.x+=speedx;
this.y-=speedy;
if (this.y<0) {
init();
}
}
function init() {
this.y=400;
this.x=Math.random()*550;
}
}
}