Ciao gente,
ho trovato un AS per simulare 'na bella nevicata.
Quello che vorrei fare è modificarlo in maniera tale che la nevicata inizi pian piano, un fiocco alla volta. Invece questo fa visualizzare da subito n fiocchi di neve (il cui numero è facilmente modificabile) su tutto lo stage.
Io sono 'na mezza sega con AS: chi riesce ad illuminarmi?
Di seguito il codice:
Codice PHP:
amount = 140;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; i<amount; i++) {
thisFlake = this.attachMovie("flake", "flake"+i, i);
with (thisFlake) {
_x = Math.random()*mWidth;
_y = Math.random()*mHeight;
_xscale = _yscale=_alpha=40+Math.random()*60;
}
thisFlake.yspeed = Math.random()*2+.2;
thisFlake.increment = -0.1+Math.random()*0.05;
thisFlake.radian = 0; //declare for actionscript 2.0
thisFlake.onEnterFrame = function() {
this.radians += this.increment;
//trace(this.radians);
this._x += Math.sin(this.radians);
this._y += this.yspeed;
if (this._y>=mHeight) {
this._y = -5;
this._x = -5+Math.random()*mWidth;
}
if (this._x>=mWidth || this._x<=0) {
this._y = -5;
this._x = -5+Math.random()*mWidth;
}
};
}