# AS2.0: setInterval/setTimout kills class properties

**URL:** <https://forum.kirupa.com/t/as2-0-setinterval-settimout-kills-class-properties/214456>\
**Category:** Uncategorized\
**Created:** [January 29, 2007, 6:18am UTC](https://forum.kirupa.com/t/as2-0-setinterval-settimout-kills-class-properties/214456 "2007-01-29T06:18:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwopitz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jwopitz/32/1556_2.png) [@jwopitz](https://forum.kirupa.com/u/jwopitz)\
**Post date:** [January 29, 2007, 6:18am UTC](https://forum.kirupa.com/t/as2-0-setinterval-settimout-kills-class-properties/214456/1 "2007-01-29T06:18:32Z")

</div>

I have this issue where I have a function that when it gets called via a setInterval (or setTimeout as I have tried both), it somehow makes my class vars undefined. I have traced it right before I call the timer, right after and then inside the following function that gets called. See below:

```auto

	
	private function onRearTireSuccess (evt:Object):Void {
		allowRandomCars = true;
		_scoreboardTimer.reset();
		_allowTorqueChange = false;
		setCarTimes();
		dispatchEvent({type:ModelLocator.UPDATE_SCOREBOARD});
		trace('onNewCar ' + currentCar);
		_nextCarTimeout = setInterval(onNewCar, _nextCarDelay);
		trace('onNewCar ' + currentCar);
	}
	
	private function onNewCar ():Void {
		trace('onNewCar ' + currentCar);
		clearInterval(_nextCarTimeout);
		if (this.currentCar <= ModelLocator.CAR_TWO){
			trace('onNewCar ' + currentCar);
			currentCar++;
			dispatchEvent({type:ModelLocator.GAME_STATUS_CONTINUE});
		} else {
			trace('end of game');
		}
	}

```

Has anyone else had this issue?
