Hey everyone,
A question someone asked me earlier was how to make the snow disappear or reappear at a certain point. For example, you may want the snow to fall in Frames 1-30, but beyond that, you would not want any snow to fall. The code I had provided in v2.0 of the tutorial did not address that, so until I write a modified tutorial, I have provided the FLAs (for MX) that help you to control when you want or don’t want the snow to fall :beam:
I have provided two variations of the Falling Snow file. One method stops or starts the falling snow by having you press a button (the white/pink circle on the bottom left of the animation). The second method displays the falling snow for about 30 frames, and then it stops displaying the falling snow.
The primary thing you will need to consider in this new version of the falling snow is your placement of:
_root.run = 1 // displays snow
- and -
_root.run = 0 // hides snow
Also, I made some minor modifications to the actual Falling Snow code found on the snow movie clip, and that can be found here:
onClipEvent (load) {
//variables
width = 300;
height = 200;
//random x,y, and alpha
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 20+Math.random()*50;
//random x and y for flakes
this._x = -width+Math.random()*(3*width);
this._y = -10+Math.random()*height;
//speed and trigonometric value
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
rad = 0;
this._visible = false;
}
onClipEvent (enterFrame) {
///////////////////
///////////////////
if (_root.run == 1) {
///////////////////
///////////////////
this._visible = true;
// horizontal movement
rad += (k/180)*Math.PI;
xmovement = _root._xmouse;
this._x -= Math.cos(rad)+(xmovement-(width/2))/50;
// vertical movement
this._y += i;
// remove clips when they misbehave (overstep boundaries)
if (this._x>(width+50)) {
this._x = -45;
this._y = Math.random()*height*2;
}
if (this._x<-50) {
this._x = width+45;
this._y = Math.random()*height*2;
}
if (this._y>=height) {
this._y = -50;
this._x = -width+Math.random()*(3*width);
}
///////////////////
///////////////////
} else {
this._visible = false;
}
///////////////////
///////////////////
}
The source files should contain everything I have explained here.
Cheers!
Kirupa :sailor: