all groups > flash actionscript > october 2005 >
You're in the

flash actionscript

group:

Stop Snowing Effect - Help!


Stop Snowing Effect - Help! TOD-The Online Devil
10/30/2005 11:02:56 PM
flash actionscript:
I found this actionscript code thing on another website.
I put it into my flash animation...
Everything is working fine, except I don't want it to run forever...

I want the snow to stop at a certain point...

What do I do? The following is the script I got...



var swidth = 550;
var sheight = 400;

// movieclip to hold our 'drops'
_root.createEmptyMovieClip("DropClip", 15999);

// setup the screen initially so it doesn't start empty
for(var i=0; i<50; i++)
{
createdrop(random(sheight));
}

// create our interval
var lightstorm = setInterval(createdrop, 100);

// our function which creates a rain/snow drop
function createdrop(y)
{
var clip = "drop" + Math.random();
_root.DropClip.attachMovie("Drop", clip, random(15999));
_root.DropClip[clip]._x = random(550);
if(y != null)
{
_root.DropClip[clip]._y = y;
}

_root.DropClip[clip]._alpha = random(100);
_root.DropClip[clip].speed = random(4);
_root.DropClip[clip].onEnterFrame = fall;
}

// our onEnterFrame function is what makes the drops
// move. we check if we can remove a clip if it's outside
// the stage, otherwise we increase the _y position
// of the drop.
function fall()
{
if(this._y < sheight)
{
this._y += 1 + this.speed;
}
else
{
delete this.onEnterFrame;
this.removeMovieClip();
}
}
Re: Stop Snowing Effect - Help! Dave Mennenoh
10/31/2005 8:23:47 AM
Stick in a flake counter and max flakes variable and check it within the
createDrop function:


var swidth = 550;
var sheight = 400;
var flakeCount = 0;
var maxFlakes = 2000;

// movieclip to hold our 'drops'
_root.createEmptyMovieClip("DropClip", 15999);

// setup the screen initially so it doesn't start empty
for(var i=0; i<50; i++)
{
createdrop(random(sheight));
}

// create our interval
var lightstorm = setInterval(createdrop, 100);

// our function which creates a rain/snow drop
function createdrop(y)
flakeCount++;
if(flakeCount < maxFlakes){
{
var clip = "drop" + Math.random();
_root.DropClip.attachMovie("Drop", clip, random(15999));
_root.DropClip[clip]._x = random(550);
if(y != null)
{
_root.DropClip[clip]._y = y;
}

_root.DropClip[clip]._alpha = random(100);
_root.DropClip[clip].speed = random(4);
_root.DropClip[clip].onEnterFrame = fall;
}
}

// our onEnterFrame function is what makes the drops
// move. we check if we can remove a clip if it's outside
// the stage, otherwise we increase the _y position
// of the drop.
function fall()
{
if(this._y < sheight)
{
this._y += 1 + this.speed;
}
else
{
delete this.onEnterFrame;
this.removeMovieClip();
}
}



--
Dave -
www.blurredistinction.com/director
www.macromedia.com/go/team

AddThis Social Bookmark Button