Flixel Power Tools FlxDelay

Back to the Flixel Power Tools

A useful timer that can be used to trigger events after certain amounts of time are up. Uses getTimer so is low on resources and avoids using Flash timer events. Also takes into consideration the Pause state of your game. If your game pauses, when it starts again the timer notices and adjusts the expires time accordingly.

Screen Shot


Code Example

Recent Flixel Power Tool Posts

  1. Flixel Power Tools v1.9 Released
  2. Flixel Power Tools v1.8 Released - Let's get clicky
  3. Flixel Power Tools v1.7 - Kaboom!
  4. Flixel Power Tools v1.6 released including FlxControl
  5. Flixel Power Tools v1.5 - A monster of an update!
  6. FlxScreenGrab and FlxScrollZone added to Flixel Power Tools
  7. Flixel Power Tools v1.3 - Now Flixel 2.5 compatible!
  8. FlxHealthBar added to Flixel Power Tools

3 Responses

Leave a comment
  • wolf
    July 14th 2011 at 3:52 pm

    Hey, this class has come in really handy with my latest project. So first off: thanks!!

    Also, I wanted to share 2 small modifications I made to it to add 2 features I needed:

    1) Sometimes I just want to restart the timer with the same duration. I changed it so that the duration only gets updated if I pass it one.

    public function reset(newDuration:int=0):void
    if (newDuration != 0) { duration = newDuration; }

    2) Sometimes a callback function that gets called when the timer is finished is more practical than constantly polling hasExpired.

    public var callback:Function; // a callback that can be set

    private function stop():void
    removeEventListener(Event.ENTER_FRAME, update);

    isRunning = false;
    complete = true;

    if (callback != null) { callback(); } // if callback has been set, call it

  • Deathcraft
    November 17th 2011 at 5:14 pm

    Thank you for your incredible classes!
    I have an issue with delay – when the flash container moves out of focus (flixel enters into tha “pause” mode with big play button overlay) my FlxDelay instance still continues the countdown. Any way to fix it? Thanks!

  • May 17th 2012 at 6:28 pm

    Thanks fpr this class, and again thank you wolf,
    I was looking for a way to delete my delay. Yours is perfect !

Make yourself heard