# setTimeout clearInterval problem

**URL:** <https://forum.kirupa.com/t/settimeout-clearinterval-problem/165091>\
**Category:** flash\
**Created:** [October 7, 2005, 2:25pm UTC](https://forum.kirupa.com/t/settimeout-clearinterval-problem/165091 "2005-10-07T14:25:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdulberg](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jdulberg](https://forum.kirupa.com/u/jdulberg)\
**Post date:** [October 7, 2005, 2:25pm UTC](https://forum.kirupa.com/t/settimeout-clearinterval-problem/165091/1 "2005-10-07T14:25:44Z")

</div>

I am using the [setTimeout](http://www.kirupa.com/forum/showpost.php?p=303481&postcount=23) function that clears the Interval _after_ it fires. In some cases, I need to clear those intervals _before_ they fire however I cannot access the interval id to do so. Any suggestions for how I could do this? Basically I need to clear ALL existing intervals before proceeding to the next. There may be more than one interval active at a time.

```auto

_global.setTimeout = function(a,b,c, args){
        // for a basic function call:
        if (typeof a == "function"){
                args = arguments.slice(2);
                var ID, func = function(){
                        a.apply(null, args);
                        clearInterval(ID);
                }
                ID = setInterval(func, b, args);
                
                // for an object method call:
        }else{
                args = arguments.slice(3);
                var ID, func = function(){
                        a**.apply(a, args);
                        clearInterval(ID);
                }
                ID = setInterval(func, c, args);
        }
        return ID;
}
_global.clearTimeout = clearInterval;

```

Any ideas would be very helpful!

Thanks.

Jason
