Enter_Frame Based Timer Class written in AS3.

Custom Timer Class’s Properties & Methods are similar to Flash’s Timer Class, that means it’s easy to switch from Flash’s Timer to Custom Timer.

Why Custom Timer Class:

  • Custom Timer Class is more accurate than Flash’s Timer Class (view differences in preview, Flash’s Timer delays a little more every second…leave preview on for some minutes then look at differences).
  • You can stop then restart from same millisecond, instead of Flash’s Timer Class where you stop then restart from last currentCount.

How to use:

  1. Place .as file in your project’s folder
  2. Import class: e.g. import com.utils.CustomTimer;
  3. Create the Timer using new operator:
    new CustomTimer(delay, callback, repeatCount, startTimer);
  4. If startTimer is false, use .start() to start timer.

Public Properties & Methods:

CustomTimer(timerDelay:int, callback:Function, repeatCount:uint = 1, startTimer:Boolean = false):void
Creates a precise Timer

start():void
Starts Timer

reset():void
Resets Timer

pause():void
Pauses Timer, use start function to unpause

create():void
Creates Timer

destroy():void
Destroyes Timer, you can create it again using create function

getSeconds(toInt:Boolean):Number
Gets Seconds elapsed from start in float number

get state():String
Timer’s state (On, Off, Paused, Finished), this property is read-only

set callback(val:Function):void
Function to run after timer finished

get callback():Function
Function to run after timer finished

set running(val:Boolean):void
true if Timer is running, false if not

get running():Boolean
true if Timer is running, false if not

get elapsedTime():int
Elapsed time from start, this property is read-only

get lastingTime()int
Lasting time until finish, this property is read-only

set delay(val:int):void
Timer Delay in milliseconds

get delay():int
Timer Delay in milliseconds

set currentCount(val:uint):void
Total Times Timer has finished since it started

get currentCount():uint
Total Times Timer has finished since it started

set repeatCount(val:uint):void
Times to repeat the Timer, if repeatCount is 0 it will repeat infinitely

get repeatCount():uint
Times to repeat the Timer, if repeatCount is 0 it will repeat infinitely

get currentCount():uint
Total Times Timer has finished since it started

set repeatCount(val:uint):void
Times to repeat the Timer, if repeatCount is 0 it will repeat infinitely

get repeatCount():uint
Times to repeat the Timer, if repeatCount is 0 it will repeat infinitely
by
by
by
by
by
by