PDA

View Full Version : Falling Snow - Showing/Hiding the Snow


kirupa
01-14-2005, 12:42 PM
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 snowAlso, 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:

xultraloveninja
01-19-2005, 03:01 PM
thanks!

that what i was looking for!

worked
10-23-2007, 09:30 AM
Thank you for posting this. Two questions.
1. How can I get the snow to fall at start, then offer the option to stop it and re-start it at will?
2. What if I wanted the button to switch between a stop symbol and start symbol, when applicable?

worked
10-24-2007, 12:12 PM
I figured out how to add a separate "on" button and "off" button for the falling snow app, while using swapDepth for the logo: example (http://www.murphydrygoods.com/logo_alt_latest_1.html)

PM me if you wish for the code. :beer:

ZZ_ka
10-25-2007, 03:01 AM
Bless You!:?)

minthu
10-25-2007, 06:17 AM
That's simply amazing codes! I like this snow effect.

Thanks!

vini
10-25-2007, 12:58 PM
Great one Kiru..
Guys check out this one
http://www.platfuse.com

worked
10-30-2007, 10:08 AM
Hey Vini- Can you post the .fla for that snow effect? I'm very interested in seeing how that works. If so, thanks in advance!