Frame 1
function snowFlake() {
trace("snowFlake");
this.reset();
}
function doLoop() {
gWindSpeed = gWindSpeed + ((Math.random() * (2 * gWindMaxChange)) - gWindMaxChange);
if (gWindSpeed > gWindMaxSpeed) {
gWindSpeed = gWindMaxSpeed;
} else if (gWindSpeed < (-gWindMaxSpeed)) {
gWindSpeed = -gWindMaxSpeed;
}
}
function initSnow() {
trace("initSnow");
i = 0;
while (i < gFlakeCount) {
_root.attachMovie("anim", "flake" + i, i);
i++;
}
resetWind();
}
function init() {
trace("init");
gZDepth = 100;
gXSpeedRange = 0.1;
gYInitSpeed = 0.04;
gPerspFactor = 1;
gWindSpeed = 0;
gWindMaxChange = 0.008;
gWindMaxSpeed = 0.12;
gFlakeCount = 500;
screenMarginWidth = 20;
}
function resetWind() {
trace("resetWind");
gWindSpeed = (Math.random() * (2 * gWindMaxSpeed)) - gWindMaxSpeed;
}
snowFlake.prototype = new MovieClip();
snowFlake.prototype.reset = function () {
this.zloc = Math.random() * (gZDepth - 20);
this.swapDepths(this.zloc);
this._x = Math.random() * Stage.width;
this._y = -20;
this._initXspeed = (Math.random() * gXSpeedRange) - (gXSpeedRange / 2);
this._yspeed = gYInitSpeed;
this.gotoAndPlay(Math.floor(Math.random() * this._totalframes));
};
snowFlake.prototype.onEnterFrame = function () {
var _local2 = gPerspFactor * (gZDepth - this.zloc);
this._xscale = _local2;
this._yscale = _local2;
this._xspeed = this._initXspeed + gWindSpeed;
this._x = this._x + (this._xspeed * _local2);
this._y = this._y + (this._yspeed * _local2);
this._rotation = this._xspeed * 360;
this._xscale = this._xscale - ((this._xspeed * _local2) * 2);
if (this._y > Stage.height) {
this.reset();
}
if (this._x > (Stage.width + screenMarginWidth)) {
this._x = (-screenMarginWidth) / 2;
} else if (this._x < (-screenMarginWidth)) {
this._x = Stage.width + (screenMarginWidth / 2);
}
};
Object.registerClass("anim", snowFlake);
init();
Frame 2
stop();
Instance of Symbol 7 MovieClip in Frame 2
onClipEvent (enterFrame) {
_root.doLoop();
}
onClipEvent (load) {
_root.initSnow();
}
onClipEvent (mouseUp) {
_root.resetWind();
}