Bit Shifter – Information Chase

Chiptune, an acquired taste.

http://www.8bitpeoples.com/discography/8BP059

Still the best regardless no-one else likes it

Advertisements

Simple delayedCall function

Im tired of constantly having to use the Timer class when all I want to do is a delayed call of a function. So I made this class, hopefully it will be useful to someone else 🙂

Its very simple, this class is static all the code you need is this,

import com.georgecrabtree.Utils;

Utils.delayedCall(1000, myFunction)

function myFunction():void {

trace(“silly hat”);

}

The first argument is the delay you want in milliseconds, the second is the function you want to call.


package com.georgecrabtree {

import flash.utils.Timer;
import flash.events.TimerEvent;

public class Utils {

public static function delayedCall($delay:Number=1000, $funct:Function=null){

if($funct==null){
$funct = function(){ trace('Delayed Call -', $delay) };
}

var timer:Timer = new Timer($delay, 1);
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent){ $funct(); timer=null});
timer.start();
}
}//end class
}//end package