# clearInterval() doesn't clear anything, help!

**URL:** <https://forum.kirupa.com/t/clearinterval-doesnt-clear-anything-help/84079>\
**Category:** Uncategorized\
**Created:** [March 24, 2005, 1:43pm UTC](https://forum.kirupa.com/t/clearinterval-doesnt-clear-anything-help/84079 "2005-03-24T13:43:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lw61v](https://avatars.discourse-cdn.com/v4/letter/l/c37758/32.png) [@lw61v](https://forum.kirupa.com/u/lw61v)\
**Post date:** [March 24, 2005, 1:43pm UTC](https://forum.kirupa.com/t/clearinterval-doesnt-clear-anything-help/84079/1 "2005-03-24T13:43:29Z")

</div>

Hi guys, can any of you point out if this code is wrong or do I have a bug in my Flash? It’s sopposed to be a simple move function, called by an interval, and after reaching the border of the film, it’s sopposed to stop. pretty simple, right? right, but the _&_&%_&^%_ thing won’t stop…

Here’s the code I’ve used: (mcBall = 1 framed movieClip)

\_root.onEnterFrame = function()  
{  
function fMoveIt():Void  
{  
mcBall.\_x += 10;  
trace(" function fMoveIt is called by setInterval, mcBall.\_x = " + mcBall.\_x);  
if (mcBall.\_x \>= (Stage.width - mcBall.width))  
{  
trace(“calling clearInterval() to stop the loop”);  
clearInterval(mcBall.intervalID);  
}  
}  
mcBall.intervalID = setInterval(fMoveIt, 50, mcBall);  
};

Here’s the Output Window:

…  
function fMoveIt is called by setInterval, mcBall.\_x = 246.7  
calling clearInterval() to stop the loop  
function fMoveIt is called by setInterval, mcBall.\_x = 256.7  
calling clearInterval() to stop the loop  
function fMoveIt is called by setInterval, mcBall.\_x = 266.7  
…  
…  
…  
function fMoveIt is called by setInterval, mcBall.\_x = 6106.7  
calling clearInterval() to stop the loop  
function fMoveIt is called by setInterval, mcBall.\_x = 6186.7  
calling clearInterval() to stop the loop  
function fMoveIt is called by setInterval, mcBall.\_x = 6196.7  
calling clearInterval() to stop the loop  
…  
…

and so on … so is it me or is it a bug? (I really hope it’s me)

Any ideas??

I’ve also uploaded the file, just in case.

thanks in advance!
