Snowflakes | Macromedia Flash
The falling snowflakes is a popular ActionScript theme. It has been done many times by numerous authors, so no innovation here :). This is in Flash 5 OOP style:
/* 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);
The code block above should be placed on the first frame of the main timeline. The following is attached to the process clip and executes on every frame:
onClipEvent(enterFrame) {
for(var i = 0; i < this._parent.count; i++) this._parent[i].dropFlake();
}
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.
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.

