# Which way is faster?

**URL:** <https://forum.kirupa.com/t/which-way-is-faster/314213>\
**Category:** flash\
**Created:** [September 21, 2010, 8:50pm UTC](https://forum.kirupa.com/t/which-way-is-faster/314213 "2010-09-21T20:50:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick23](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@Nick23](https://forum.kirupa.com/u/Nick23)\
**Post date:** [September 21, 2010, 8:50pm UTC](https://forum.kirupa.com/t/which-way-is-faster/314213/1 "2010-09-21T20:50:56Z")

</div>

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.

```auto
...
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

```auto
...
public function main(e:Event){/*...*/}
public function mousePress(e:MouseEvent){timer.start();}
public function timerDone(e:TimerEvent){timer.reset(); trace("Hello!!");}

```

Thanks so much!
