Falling Tiles in Flash 5 (ActionScript 1.0)

Download Source File: Flash5_Tiles.zip

On the first frame of the main timeline we define 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();
}