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() {
var _local1 = _root;
trace("initSnow");
i = 0;
while (i < gFlakeCount) {
_local1.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 () {
var _local1 = this;
_local1.zloc = Math.random() * (gZDepth - 20);
_local1.swapDepths(_local1.zloc);
_local1._x = Math.random() * Stage.width;
_local1._y = -20;
_local1._initXspeed = (Math.random() * gXSpeedRange) - (gXSpeedRange / 2);
_local1._yspeed = gYInitSpeed;
_local1.gotoAndPlay(Math.floor(Math.random() * _local1._totalframes));
};
snowFlake.prototype.onEnterFrame = function () {
var _local1 = this;
var _local2 = gPerspFactor * (gZDepth - _local1.zloc);
_local1._xscale = _local2;
_local1._yscale = _local2;
_local1._xspeed = _local1._initXspeed + gWindSpeed;
_local1._x = _local1._x + (_local1._xspeed * _local2);
_local1._y = _local1._y + (_local1._yspeed * _local2);
_local1._rotation = _local1._xspeed * 360;
_local1._xscale = _local1._xscale - ((_local1._xspeed * _local2) * 2);
if (_local1._y > Stage.height) {
_local1.reset();
}
if (_local1._x > (Stage.width + screenMarginWidth)) {
_local1._x = (-screenMarginWidth) / 2;
} else if (_local1._x < (-screenMarginWidth)) {
_local1._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();
}