Create Water Bubbles using Flash Actionscript 3.0 (AS3)
This a small example that shows how to create bubbles in flash
var bubbleCount:Number = 30;
var mWidth:Number = Stage.width;
var mHeight:Number = Stage.height;
var i = 0;
var minSpeed:Number = 2;
for (var i=0;i<bubbleCount;i++) {
var bubble = this.attachMovie("bubble", "bubble" + i, i);
bubble._x = Math.random() * mWidth;
bubble._y = Math.random() * mHeight;
bubble._xscale = bubble._yscale = bubble._alpha = 40 + Math.random() * 60;
bubble.yspeed = Math.random() * 3 + minSpeed;
bubble.onEnterFrame = function ()
{
this._y = this._y - this.yspeed;
if (this._y <= 0)
{
this._y = 400;
this._x = 10 + Math.random() * mWidth;
}
if (this._x >= mWidth || this._x <= 0)
{
this._y = 400;
this._x = 10 + Math.random() * mWidth;
}
};
}
This is sample application with above code
This movie requires Flash Player 9