The Timer object is the interface to timers, which let you run code on a specified time sequence. Use the start() method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.

You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending on the application framerate or the runtime environment (available memory and other factors), the runtime may dispatch events at slightly offset intervals. For example, if a application is set to play at 10 frames per second (fps), which is 100 millisecond intervals, but your timer is set to fire an event at 80 milliseconds, the event will be dispatched close to the 100 millisecond interval. Memory-intensive scripts may also offset the events.


Inherited from EventDispatcher.


Can be created using method new:

Lib.Media.Utils.Timer.new(delay, repeatCount)

Constructs a new Timer object with the specified delay and repeatCount states.

delay - The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems.

repeatCount - (default = 0) - Specifies the number of repetitions. If zero, the timer repeats indefinitely, up to a maximum of 24.86 days (int.MAX_VALUE + 1). If nonzero, the timer runs the specified number of times and then stops.


Created Timer object has properties:

currentCount

[read-only] The total number of times the timer has fired since it started at zero.

delay

The delay, in milliseconds, between timer events.

repeatCount

The total number of times the timer is set to run.

running

[read-only] The timer's current state; true if the timer is running, otherwise false.


methods:

reset()

Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch.


start()

Starts the timer, if it is not already running.


stop()

Stops the timer.



Events: TimerEvent

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation