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:
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?