The life, work and thoughts of Bence Kucsan - There are 0 new posts and 0 new comments since Your last visit
In this tutorial I share an impressive way - found a couple days ago - to make real snow effect in flash. Just a few lines of ActionScript.
Well, you can put a smile on your face, just as I did, when I found a great tutorial and modified it to make a nice snow falling effect, just like this:
To easily recreate this as step one make a movie with a white small bubble, then as step two attach this few lines of ActionScript:
amount = 100;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; 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.025+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 = -10;
this._x = -10+Math.random()*mWidth;
}
if (this._x>=mWidth || this._x<=0) {
this._y = -10;
this._x = -10+Math.random()*mWidth;
}
};
}
You can simply modify the amount of the white snow bubbles editing the first “amount=100” line.
Your thoughts are welcome!
Make your voice heard, fill out the comment form below and don't be shy to hit that big blue button.
Hi, very nice snow
but i think you forgot something on the code;
here is the updated one
Thanks
amount = 100;
mWidth = Stage.width;
mHeight = Stage.height;
for (var i = 0; i <= amount; i++) { // you miss out this part =}
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+.8;
thisFlake.increment = -0.025+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 = -10;
this._x = -10+Math.random()*mWidth;
}
if (this._x>=mWidth || this._x<=0) {
this._y = -10;
this._x = -10+Math.random()*mWidth;
}
}
}
coolerman intermatch subchloride parahormone overreliant discoactine twanky cordwain
<a href= http://www.cbc.ca/business/ >CBC Business News</a>
http://www.danielslakelodge.com/
Hi! I’ve read this post - and I think you really smart in AS. Please visit my flash menu builder
Is it OK? I’m working on it all my time. And sometimes there’re really hard coding :)
coolerman intermatch subchloride parahormone overreliant discoactine twanky cordwain
<a href= http://www.northwestern.edu/lutheran/ >University Lutheran Church at Northwestern</a>
http://members.tripod.com/~SAPBTC/rescues.htm
5 comments, add yours!