Hey there. I have trawled the threads for an answer to this question, but none do what I want.
I have the snow falling tutorial working great, with a little random rotation thrown in for good measure, but what I need is for the snow to NOT disappear from the ‘borders’ of the movie.
I want it to snow normally with the ‘wind’ effect, but need to script it so that a snowflake never reaches the boundary on either left or right. It should drift back into the main area. This is not hard right? Just can’t do it myself.
Thanks for all the great tips.
onClipEvent (load) {
//specifies the max and min of snowfall area
var xmin = 0, xmax = 300, ymin = 0, ymax = 360;
//variables that modify the speed and amount falling snow
i = 0.5+Math.random()*1.5;
k = -Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=70+Math.random()*250;
this._alpha = 80+Math.random()*100;
this._x = xmin+Math.random()*(xmax-xmin);
this._y = ymin;
spin = (Math.random() * 6) - 3;
}
onClipEvent (enterFrame) {
//spinning the flake
this._rotation = this._rotation + spin;
//drifting the flake
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=ymax || this._x<=xmin || this._x>=xmax) {
this._x = xmin+Math.random()*(xmax-xmin);
this._y = ymin;
}
}