Animated widgets in Gravity Field | Macromedia Flash

Macromedia Flash 5   Download SWF    Download zipped FLA

On the first frame of the main timeline we create these movieclip methods:

MovieClip.prototype.reset = function(){
	this._alpha = 0;
	this._rotation = 0;
	this._velocity = 0;
	this._roll = 10 - 20 * Math.random();
	this._x = 16 + 32 * Math.floor(18 * Math.random());
	this._y = 16 + 32 * Math.floor(6 * Math.random());
}

MovieClip.prototype.fall = function(){
	if(this._alpha < 100) this._alpha += 10;
	else{
		this._y += this._velocity;
		this._velocity += 2;
		this._rotation += this._roll;
	}
	if(this._y > 432) this.reset();
}

This code block goes inside the host clip. First we attach 10 instances of the "box" library item and then start the animation.

onClipEvent (load){
	for(i = 0; i < 10; i++){
		this.attachMovie("box", i, i);
		this[i].reset();
		this[i]._alpha = 0 - 50 * i;
	}
}

onClipEvent (enterFrame){
	for(i = 0; i < 10; i++) this[i].fall();
}
COMMENTS ARE CLOSED
Sorry, I do not have time to answer questions related to these scripts.
You can always get help on the Kirupa Flash Forums. Thank you for visiting.