# Stop a function on rollout (n00b question)

**URL:** <https://forum.kirupa.com/t/stop-a-function-on-rollout-n00b-question/217277>\
**Category:** flash\
**Created:** [February 25, 2007, 3:42am UTC](https://forum.kirupa.com/t/stop-a-function-on-rollout-n00b-question/217277 "2007-02-25T03:42:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spastic](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@spastic](https://forum.kirupa.com/u/spastic)\
**Post date:** [February 25, 2007, 3:42am UTC](https://forum.kirupa.com/t/stop-a-function-on-rollout-n00b-question/217277/1 "2007-02-25T03:42:16Z")

</div>

In flash 8, I have a movie clip(“mc”), and when you roll over it, it runs a script that makes sparks. What I’d like to do is have the script STOP running when you roll out, but I’m not sure how to do this. Can anyone help? Here’s the script:

[AS]mc.onRollOver = function() {  
// Create spark  
sparkCount = 0;  
function makeSpark() {  
sparkCount++;  
var spark = attachMovie(“spark”, “spark”+sparkCount, sparkCount);  
spark.\_x = 275;  
spark.\_y = 200;  
spark.g = 0;  
spark.yMovement = Math.random()_12-6;  
spark.xMovement = -Math.random()10-14;  
spark.onEnterFrame = movIt;  
}  
//  
//Move spark  
movIt = function () {  
this.\_alpha-=2;  
if(this.\_alpha\<4)this.removeMovieClip();  
this.\_y -= this.yMovement=.95;  
this.\_x += this.xMovement+=1;  
if(this.\_x\>250){  
this.xMovement_=-.6;  
this.\_x = 250;  
}  
};  
//  
// Start shooting sparks  
setInterval(makeSpark, 10);  
//  
//  
}  
[/AS]

Thanks in advance!
