# How can i stop a function?

**URL:** https://forum.kirupa.com/t/how-can-i-stop-a-function/186668
**Category:** Uncategorized
**Created:** [April 23, 2006, 1:57pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668 "2006-04-23T13:57:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nico](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@nico](https://forum.kirupa.com/u/nico)
#### Post date: [April 23, 2006, 1:57pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/1 "2006-04-23T13:57:15Z")

</div>

i have this title screen with some falling leaves, similar to the snow present here in kirupa. the problem is, when the scene is now in the gameplay, there still some falling leaves, how can i make this function stop.

---

<div class="post-metadata">

### Author: ![Nich](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@Nich](https://forum.kirupa.com/u/Nich)
#### Post date: [April 23, 2006, 3:40pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/2 "2006-04-23T15:40:27Z")

</div>

The simplest way I can think of is put your code in an if - else statement, with a boolean. Something like:

```auto

if(!cutscene)
{
      //your snow code

}
else
{
    //remove snow
}

```

Then when you enter the cutscene, set cutscene to true. The code you would use to remove the snow depends on how you’re creating it.

---

<div class="post-metadata">

### Author: ![nico](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@nico](https://forum.kirupa.com/u/nico)
#### Post date: [April 24, 2006, 3:10pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/3 "2006-04-24T15:10:44Z")

</div>

i get your point, but the code seems to look a bit ahm… un accurate, can u think of another method.  
by the way here is the code:

//snow function

snowfall = function () {

```
width = 800;
// pixels
height = 600;
// pixels
max_snowsize = 10;
// pixels
snowflakes = 50;
// quantity
for (i=0; i&lt;snowflakes; i++) {

x = attachMovie("snow", "snow"+i, i);
x._alpha = 20+Math.random()*60;
x._x = -(width/2)+Math.random()*(1.5*width);
x._y = -(height/2)+Math.random()*(1.5*height);
x._xscale = t._yscale=50+Math.random()*(max_snowsize*10);
x.k = 1+Math.random()*2;
x.wind = -1.5+Math.random()*(1.4*3);
x.onEnterFrame = mover;

}

};
mover = function() {

this._y += this.k;
this._x += this.wind;
if (this._y&gt;height+10) {

this._y = -20;

}
if (this._x&gt;width+20) {

this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;

} else if (this._x&lt;-20) {

this._x = -(width/2)+Math.random()*(1.5*width);
this._y = -20;

}

}
snowfall();

```

//end of snow function

---

<div class="post-metadata">

### Author: ![KIERIOSHIMOTO](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@KIERIOSHIMOTO](https://forum.kirupa.com/u/KIERIOSHIMOTO)
#### Post date: [April 25, 2006, 1:51pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/4 "2006-04-25T13:51:04Z")

</div>

or you could just use unloadMovie

---

<div class="post-metadata">

### Author: ![nico](https://avatars.discourse-cdn.com/v4/letter/n/b5a626/32.png) [@nico](https://forum.kirupa.com/u/nico)
#### Post date: [April 25, 2006, 11:42pm UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/5 "2006-04-25T23:42:41Z")

</div>

thank you very much joex4, you really helped me alot… also to others who helped me here…

another thing…

how can i make the background scroll, do you want me to show the fla for you t create an engine.???

---

<div class="post-metadata">

### Author: ![joran420](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joran420/32/2329_2.png) [@joran420](https://forum.kirupa.com/u/joran420)
#### Post date: [April 26, 2006, 12:47am UTC](https://forum.kirupa.com/t/how-can-i-stop-a-function/186668/6 "2006-04-26T00:47:26Z")

</div>

If you want to pause it just do  
mySnowClip.onEnterFrame = null

when you want to stop it and set it back when you want to make it go again
