I am making a flash game and I am trying to make it as efficient as possible. I need to set a timer and then do something after the timer runs out.
So, that being said I am wondering which method would be faster (or more efficient):
Making a timer object and listening to the TimerEvent.TIMER_COMPLETE or in the ENTER_FRAME event of the game checking a Boolean (time) and then if it is true, incrementing a variable until that variable is equal to x, then performing the operations.
...
public function main(e:Event){if (time){
if (timer++>=TOTAL_TIME){timer =0; time = false; trace("Hello!");}}
public function mousePress(e:MouseEvent){time = true;}
or
...
public function main(e:Event){/*...*/}
public function mousePress(e:MouseEvent){timer.start();}
public function timerDone(e:TimerEvent){timer.reset(); trace("Hello!!");}
Thanks so much!