Interval

Kind of class:class
Inherits from:Timer < EventDispatcher < CoreObject
Version:04/19/07
Author:Aaron Clinger, Toby Boudreaux, Mike Creighton
Classpath:org.casalib.time.Interval
File last modified:Monday, 01 December 2008, 13:34:40
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
Class methods
  • setInterval (scope:Object, methodName:String, delay:Number, param:Object) : Interval
    • Calls a function or a method of an object at periodic intervals.
  • 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.
  • stopIntervals (scope:Object) : Void
    • Stops all intervals in a defined location.
Instance methods
  • setReps (reps:Number) : Void
    • Defines the amount of total repetitions/fires.
  • destroy : Void

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:

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:

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.