Custom setInterval replacement class - Timer from Misuta Hagane Util package

need for replacemenr of setInterval in AS2.0 is obvious, it happened to me and to other people many times that clearInterval just won’t work… it’s basiclly in only 1% of cases but it’s enough
so to help me and my friends I’ve created Timer class which fits into Misuta Hagane Utils package, which will soon get extension with some other interesting things (Misuta Hagane is my alias in Japanese language // my new homepage

blog post :

[URL=“”]MHU Package / Timer Class

initializing the class

  • place com.hagane.MHU folder in root of your project
  • import in flash project via AS[INDENT]import com.hagane.MHU.Timer; *
    [/INDENT]- create instance of the class[INDENT]
    var timeKeeper : Timer = new Timer();*
    [/INDENT]being that my class creates movieclip for enterframe events, by default it’s 32760 and it’s created in root and named timer, I made it possible that you tell in constructor what mc to use for timer
    In that case you create instance like this[INDENT]var mc:MovieClip = _root.createEmptyMovieClip(”mc”, 50);
    var timeKeeper : Timer = new Timer(mc);

    [/INDENT]** add interval function call**[INDENT]var intervalID_mc : Number = timeKeeper.intervalCall(time:Number, repeat:Number, func:Function, param: Parameters…);
    [/INDENT][INDENT] time:Number - time in ms
    *repeat *: Number - number of repeating, 0 and 1 for once, -1 for infinite
    *func *: Function - function to call
    *param *: Parameters - can be anything that fits into parameters of func - function you decided to call
    [/INDENT]function returns ID of your interval, which you will later use to clear interval
    for example[INDENT]var intervalID_num : Number = timeKeeper.intervalCall(999, 5, traceABC, 3, 5, 6, “myInterval”);
    [/INDENT]clearing interval[INDENT]timeKeeper.clearIntervalCall(intervalID:Number);
    [/INDENT]In archive file you have everything set up for testing.
    You will see main action is taking place in which is included in first frame of FLA file.
    [URL=“”]MHU Package / Timer Class

if you have any question SHOOT!