# What keeps my movie from stopping properly? Math.floor/interval

**URL:** <https://forum.kirupa.com/t/what-keeps-my-movie-from-stopping-properly-math-floor-interval/264646>\
**Category:** flash\
**Created:** [June 28, 2008, 4:45am UTC](https://forum.kirupa.com/t/what-keeps-my-movie-from-stopping-properly-math-floor-interval/264646 "2008-06-28T04:45:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dualaud](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@dualaud](https://forum.kirupa.com/u/dualaud)\
**Post date:** [June 28, 2008, 4:45am UTC](https://forum.kirupa.com/t/what-keeps-my-movie-from-stopping-properly-math-floor-interval/264646/1 "2008-06-28T04:45:34Z")

</div>

Hey all,

this is driving me nuts.  
I have a movie, in it lies a button with which I jump to another position in the \_root timeline.  
At that position is a stop(); command.

The movie just wont stop while this is running in another mc1 deeper in the file  
:

```auto
stop();
onEnterFrame = function() {
	
c=Math.floor(Math.random() * (1500 - 0)) + 150;

var Interval1 = setInterval(function () {
b=Math.floor(Math.random() * (7 - 0)) + 1;
gotoAndPlay(b);
clearInterval(Interval1);
}, c);
}

```

What this does in the mc1 is basically creating a random number between 150 and 1500 and a random number between 0 and 7, then jumping to a random frame (numbered from 1-7) after waiting for a random time (150-1500ms).

My \_root stops properly when I remove the code posted above.  
Why is this happening and how can I have a mc1 in my movie which waits for a random time and then jumps to a random frame, while I want to move around in my \_root timeline?  
I should add, the mcs1 which wait and move to a random frame are non existent on the position I want to move to in \_root.

Could that be part of the problem?  
Do I have to somehow remove the wait and choose random frame to jump to function in mc1, when moving around in \_root? :crying:

How would i do this?

Any help is greatly appreciated,  
dual

---

<div class="post-metadata">

**Author:** ![dlgamer](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dlgamer](https://forum.kirupa.com/u/dlgamer)\
**Post date:** [June 29, 2008, 12:11am UTC](https://forum.kirupa.com/t/what-keeps-my-movie-from-stopping-properly-math-floor-interval/264646/2 "2008-06-29T00:11:04Z")

</div>

If your frame rate is more than 6 fps (which I’m sure it is) then the onEnterFrame function is always triggered in less the 150ms, meaning the interval is reset before the interval is ever completed.
