Interval
Kind of class: | public class |
---|---|
Package: | org.casalib.time |
Inherits from: | Timer |
Implements: | |
Version: | 12/11/08 |
Author: | Aaron Clinger, Mike Creighton |
Classpath: | org.casalib.time.Interval |
File last modified: | Wednesday, 31 December 2008, 20:18:28 |
To be used instead of
Advantages over
flash.utils.setInterval
and flash.utils.setTimeout
functions.Advantages over
setInterval
/setTimeout
:- Ability to stop and start intervals without redefining.
- Change the time (
delay
), call back and arguments without redefining. - Included
repeatCount
for intervals that only need to fire finitely. - setInterval and setTimeout return an object instead of interval id for better OOP structure.
- Built in events/event dispatcher.
Example:
-
package { import flash.display.MovieClip; import org.casalib.time.Interval; public class MyExample extends MovieClip { protected var _interval:Interval; public function MyExample() { super(); this._interval = Interval.setInterval(this._repeatingFunction, 1000, "CASA"); this._interval.repeatCount = 3; this._interval.start(); } protected function _repeatingFunction(name:String):void { trace(name); } } }
Summary
Instance properties
Class methods
- setInterval (callBack:Function, delay:Number, arguments) : Interval
- Runs a function at a specified periodic interval.
- setTimeout (callBack:Function, delay:Number, arguments) : Interval
- Runs a function at a specified periodic interval.
Instance methods
- removeEventsForType (type:String) : void
- Removes all events of a specific type.
- removeEventsForListener (listener:Function) : void
- Removes all events that report to the specified listener.
- removeEventListeners : void
- Removes all event listeners.
- destroy : void
- Removes any event listeners and stops all internal processes to help allow for prompt garbage collection.
- destroy : void
Instance properties
arguments
public arguments:Array(read,write)The arguments to be passed to the call back function when executed.callBack
public callBack:Function(read,write)The function to execute after specified delay.destroyed
public destroyed:Boolean(read)Class methods
setInterval
Runs a function at a specified periodic interval.Parameters:callBack :The function to execute after specified delay.delay :The time in milliseconds between calls.arguments:The arguments to be passed to the call back function when executed.Returns:- An Interval reference.
setTimeout
Runs a function at a specified periodic interval. Acts identically like setInterval exceptsetTimeout
defaultsrepeatCount
to1
.Parameters:callBack :The function to execute after specified delay.delay :The time in milliseconds between calls.arguments:The arguments to be passed to the call back function when executed.Returns:- An Interval reference.
Instance methods
destroy
public function destroy () : voidRemoves any event listeners and stops all internal processes to help allow for prompt garbage collection.#
Always calldestroy()
before deleting last object pointer.Specified by:removeEventListeners
public function removeEventListeners () : voidRemoves all event listeners.#Specified by:removeEventsForListener
public function removeEventsForListener (listener:Function) : voidRemoves all events that report to the specified listener.#Parameters:listener:The listener function that processes the event.#Specified by: - removeEventListeners : void
- removeEventsForListener (listener:Function) : void