Bubbles [FMX]

Hi Folks,

Looks like a place to be - great another fine flash-forum. Just some bubbles to play around!


function setBubbles(obj, depth, xPos, yPos, maxNum, randHeight, randWidth, Height, Width) {
	this.createEmptyMovieClip(obj, depth);
	this[obj]._x = xPos;
	this[obj]._y = yPos;
	for (var i = 1; i <= maxNum; i++) {
		this[obj].attachMovie("blase", "blup" + i,depth + i);
		this[obj]["blup" + i].tempo = random(7) + 5;
		this[obj]["blup" + i].randVal = random(4);
		this[obj]["blup" + i].direction = -1;
		this[obj]["blup" + i].ZS = random(50) + 10;
		this[obj]["blup" + i]._xscale = this[obj]["blup" + i].ZS;
		this[obj]["blup" + i]._yscale = this[obj]["blup" + i].ZS;
		this[obj]["blup" + i]._y = random(randHeight);
		this[obj]["blup" + i]._x = random(randWidth);
		this[obj]["blup" + i].onEnterFrame = function() {
			this._y -= this.tempo;
			this._x -= this.randVal;
			this.randVal += this.direction;
			if (this._y <= 0) {
				this._y = Height;
				this.randVal = random(4);
				this.tempo = random(7) + 5;
				this.ZS = random(50) + 10;
			}
			if (this._x <= 0) {
				this._x = Width - this._width;
			}
			if (this._x >= Width) {
				this._x = 0 + this._width;
			}
			if (this.randVal < -3) {
				this.direction = +1;
			}
			if (this.randVal > 3) {
				this.direction = -1;
			}
		};
	}	
}

setBubbles("room", 1, 0, 0, 30, 400, 550, 400, 550);

Examples:
Aqualand
Three Rows

You need an mc with an linkage name!

Here a version with a flow parameter:


function setBubbles(obj, depth, xPos, yPos, maxNum, randHeight, randWidth, Height, Width, Flow) {
	this.createEmptyMovieClip(obj, depth);
	this[obj]._x = xPos;
	this[obj]._y = yPos;
	for (var i = 1; i <= maxNum; i++) {
		this[obj].attachMovie("blase", "blup" + i,depth + i);
		this[obj]["blup" + i].tempo = random(7) + 5;
		this[obj]["blup" + i].randVal = random(4);
		this[obj]["blup" + i].direction = -1;
		this[obj]["blup" + i].ZS = random(50) + 10;
		this[obj]["blup" + i]._xscale = this[obj]["blup" + i].ZS;
		this[obj]["blup" + i]._yscale = this[obj]["blup" + i].ZS;
		this[obj]["blup" + i]._y = random(randHeight);
		this[obj]["blup" + i]._x = random(randWidth);
		this[obj]["blup" + i].onEnterFrame = function() {
			angle+=.635;
			this._y -= this.tempo;
			this._x -= this.randVal;
			 this.randVal=Math.sin(angle)*random(8)+Flow
			this.randVal += this.direction;
			if (this._y <= 0) {
				this._y = Height;				
				this.tempo = random(7) + 5;
				this.ZS = random(50) + 10;
			}
			if (this._x <= 0) {
				this._x = Width - this._width;
			}
			if (this._x >= Width) {
				this._x = 0 + this._width;
			}			
		};
	}	
}

setBubbles("room", 1, 0, 0, 30, 400, 550, 400, 550, -6);

yours
Matze K.

nice bubbles, Madokan.

Do you have a step by step tutorial for making this?