TimerEvent.TIMER_COMPLETE within case
I stumbled upon a problem while converting a part of my game’s code from else if to switch case.
I use the following code to start a power-up:
ActionScript Code:
case "high": { trace ("powerup: starting speedup"); Main.reqjecSpeedBuffer = Main.reqjecSpeed; Main.reqjecSpeed *= 2; msPerUpdate = int( 1000 / frameRate ); totalUpdates = int( powerupDuration * 1000 / msPerUpdate ); timer = new Timer( msPerUpdate, totalUpdates ); timer.addEventListener( TimerEvent.TIMER_COMPLETE, unhigh ); timer.start(); break; } // case
I use the following code to terminate the power-up:
ActionScript Code:
private static function unhigh( event:TimerEvent = null ): void { trace ("powerup: speedup ended"); Main.reqjecSpeed = Main.reqjecSpeedBuffer; cleanup(); }
For some reason the TimerEvent.TIMER_COMPLETE is never triggered. I used to work when I was using if else instead of switch case. Any idea what is causing this?
Original post by TheFly