# Escaping a SetInterval?

**URL:** <https://forum.kirupa.com/t/escaping-a-setinterval/204628>\
**Category:** Uncategorized\
**Created:** [October 21, 2006, 5:45pm UTC](https://forum.kirupa.com/t/escaping-a-setinterval/204628 "2006-10-21T17:45:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stahler](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/stahler/32/2905_2.png) [@stahler](https://forum.kirupa.com/u/stahler)\
**Post date:** [October 21, 2006, 5:45pm UTC](https://forum.kirupa.com/t/escaping-a-setinterval/204628/1 "2006-10-21T17:45:15Z")

</div>

Im tyring to have something happen in waves.

I want to dynamicly stop and restart a SetInterval loop i’m in. Because of the variable changing it would make more sense logicly if I looped things outside the setinterval

(rather than within the interval itself)

is this a bad idea / how would I accomplish this?

---

<div class="post-metadata">

**Author:** ![stahler](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/stahler/32/2905_2.png) [@stahler](https://forum.kirupa.com/u/stahler)\
**Post date:** [October 24, 2006, 2:50am UTC](https://forum.kirupa.com/t/escaping-a-setinterval/204628/2 "2006-10-24T02:50:46Z")

</div>

I am revisiting this again. I can’t figure out why this locks the system up… All that I could imagine it being was that the while(!gameover) outer loop was executing too fast,

so i tried to wrap that in an interval to check … but it still crashes

new attempt:

```auto

start_level = 1;
OUTER_ID = setInterval(OuterGame,500);

function OuterGame(){
    
    game_over =0;
    //initiate ball droppping
    while(game_over==0){
    if(start_level==1){
        start_level = 0;
        ID = setInterval(DropBall, my_interval);
    }
}
}

```
