Snowflakes in Flash 5 (ActionScript 1.0)

Falling snowflakes is a popular theme.

Download Source File: Flash5_Snowflakes.zip

The following code block must be placed on the first frame of the main timeline.

/* Move Flake
************************/
MovieClip.prototype.dropFlake = function() {
	var phase = this._parent.phase += 0.0001;
	if(phase > 2 * Math.PI) this._parent.phase -= 2 * Math.PI;
	this._y += this._xscale/15;
	this._x += this._xscale * Math.sin(phase + this._y/100) / 30;
	if(this._y > this._parent.height) this.resetFlake();
}

/* Reset Flake Position
************************/
MovieClip.prototype.resetFlake = function() {
	this._xscale = this._yscale = 25 + 40 * Math.random();
	this._x = -40 + (this._parent.width + 80) * Math.random();
	this._y = -10 * Math.random();
}

/* Generate Snow Cloud
************************/
MovieClip.prototype.makeCloud = function(name, count, width, height, depth) {
	this.attachMovie("empty", name, depth);
	var mc = this[name];
	mc.count = count;
	mc.width = width;
	mc.height = height;
	for(var i = 0; i < count; i++) {
		mc.attachMovie("flake", i, i);
		mc[i].resetFlake();
		mc[i]._y = -height * Math.random();
	}
}

/* Program Execution
************************/
this.makeCloud("cloud", 100, 576, 240, 1);

This code is attached to the process movieclip and executes on every frame:

onClipEvent(enterFrame) {
	for(var i = 0; i < this._parent.count; i++) this._parent[i].dropFlake();
}