Interval

Kind of class:class
Inherits from:Timer < EventDispatcher < CoreObject
Version:03/13/07
Author:Aaron Clinger, Toby Boudreaux, Mike Creighton
Classpath:org.casaframework.time.Interval
File last modified:Monday, 09 April 2007, 09:26:53
To be used instead of built in setInterval function.

Advantages over setInterval:
  • Auto stopping/clearing of intervals if method called no longer exists.
  • Ability to stop and start intervals without redefining.
  • Change the delay with Timer.changeDelay without redefining.
  • Included setReps for intervals that only need to fire finitely.
  • setInterval returns object instead of interval id for better OOP structure.
  • Built in events/event dispatcher.
Example:
function exampleFire(firstName:String):Void {
    trace("exampleFire called and passed firstName = " + firstName);
}

var example_si:Interval = Interval.setInterval(this, "exampleFire", 1000, "Aaron");
this.example_si.setReps(3);
this.example_si.start();

Summary

Class properties
Class properties inherited from Timer
Instance properties
Instance properties inherited from Timer
Instance properties inherited from EventDispatcher
Instance properties inherited from CoreObject

Class methods

setInterval

static function setInterval (
scope:Object, methodName:String, delay:Number, param:Object) : Interval
Calls a function or a method of an object at periodic intervals.
Parameters:
scope :
An object that contains the method specified by "methodName".
methodName:
A method that exists in the scope of the object specified by "scope".
delay :
The time in milliseconds between calls.
param(s) :
[optional] Parameters passed to the function specified by "methodName". Multiple parameters are allowed and should be separated by commas: param1,param2, ...,paramN
Returns:
Interval reference.

setTimeout

static function setTimeout (
scope:Object, methodName:String, delay:Number, param:Object) : Interval
Calls a function or a method of an object once after time has elasped, setTimeout defaults setReps to 1.
Parameters:
scope :
An object that contains the method specified by "methodName".
methodName:
A method that exists in the scope of the object specified by "scope".
delay :
The time in milliseconds between calls.
param(s) :
[optional] Parameters passed to the function specified by "methodName". Multiple parameters are allowed and should be separated by commas: param1,param2, ...,paramN
Returns:
Interval reference.

stopIntervals

static function stopIntervals (
scope:Object) : Void
Stops all intervals in a defined location.
Parameters:
scope:
[optional] Object reference that contains a method referenced by one or more Interval instance. If scope is undefined, stopIntervals will stop all running intervals.
See also:

Instance methods

destroy

function destroy (
) : Void
Overrides:

setReps

function setReps (
reps:Number) : Void
Defines the amount of total repetitions/fires. If not set repetitions will continue until Timer.stop is called.
Parameters:
reps:
The amount of repetitions.