-
need to stop the snow
Hey y'all,
I found this script that creates snowfall but I cannot get the snow to stop using removeMovieClip. Im not so good when it comes to writing my own script. Someone please help my make the snow stop after its been playing for 4 seconds.
Here is the Code:
width = 721;
height = 302;
total = 200;
for (var t = 0; t != total; t++) {
var mc = _root.attachMovie("snowflake", "snowflake"+t, _root.getNextHighestDepth());
mc._x = (Math.random()*(width+20))-10;
mc._y = (Math.random()*(height+20))-10;
mc.yspeed = (Math.random()*1.75)+0.25;
mc.speed = (Math.random()*3)+2;
mc._xscale = mc._yscale=(mc.speed+mc.yspeed)*10;
mc.onEnterFrame = function() {
var angle = Math.atan2(_root._xmouse-(width/2), _root._ymouse)+1.5707963267949;
this._y += Math.abs(Math.sin(angle)*this.speed)+this.yspeed;
this._x += Math.cos(angle)*this.speed;
if (this._x>width+10) {
this._x = -10;
} else if (this._x<0-10) {
this._x = width+10;
}
if (this._y>height+10) {
this._y = -10;
} else if (this._y<0-10) {
this._y = height+10;
}
};
}
-
Maybe you can adapt this to what you are trying to do...
Code:
var width = 721;
var height = 302;
var total = 200;
var stopSnow = false;
function doneSnow() {
clearInterval(intID);
stopSnow = true;
}
var intID = setInterval(doneSnow, 4000);
for (var t = 0; t != total; t++) {
var mc = _root.attachMovie("snowflake", "snowflake" + t, _root.getNextHighestDepth());
mc._x = (Math.random() * (width + 20)) - 10;
mc._y = (Math.random() * (height + 20)) - 10;
mc.yspeed = (Math.random() * 1.75) + 0.25;
mc.speed = (Math.random() * 3) + 2;
mc._xscale = mc._yscale = (mc.speed + mc.yspeed) * 10;
mc.onEnterFrame = function() {
var angle = Math.atan2(_root._xmouse - (width / 2), _root._ymouse) + 1.5707963267949;
this._y += Math.abs(Math.sin(angle) * this.speed) + this.yspeed;
this._x += Math.cos(angle) * this.speed;
if (this._x > width + 10) {
this._x = -10;
} else if (this._x < 0 - 10) {
this._x = width + 10;
}
if (this._y > height + 10) {
this._y = -10;
if (stopSnow){
this.removeMovieClip()
}
} else if (this._y < 0 - 10) {
this._y = height + 10;
}
};
}
-
works beautifully, thanks man. I appreciate the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|