# setInterval function and counter var not clearing!

**URL:** <https://forum.kirupa.com/t/setinterval-function-and-counter-var-not-clearing/241650>\
**Category:** flash\
**Created:** [October 16, 2007, 4:02pm UTC](https://forum.kirupa.com/t/setinterval-function-and-counter-var-not-clearing/241650 "2007-10-16T16:02:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![natronp](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@natronp](https://forum.kirupa.com/u/natronp)\
**Post date:** [October 16, 2007, 4:02pm UTC](https://forum.kirupa.com/t/setinterval-function-and-counter-var-not-clearing/241650/1 "2007-10-16T16:02:58Z")

</div>

i’m reusing a function as a timer with setInterval. it works the first time around but then for some reason the counter var gets stuck at 10 (the delay var = 10) and won’t reset and start counting up from zero again…

code:

```auto
_global.count=0;

startTimer1=function(){
	trace("COUNT: "+count);
	trace("timer!");
	if (count==delay){
		_global.count=0;
		trace("switch!");
		if(disSet==1){
			trace("switchin to 2nd set");
			clearInterval(sInt1);
			_global.count=0;
			firstSetOut();
			
		}
		if(disSet==2){
			trace("switchin to 1st set");
			clearInterval(sInt1);
			_global.count=0;
			secondSetOut();
		_global.count=0;
		}
	}else{
		count++;
	}
	
}

```
