Chain

Kind of class:class
Inherits from:EventDispatcher < CoreObject
Implements:
Known subclasses:
Version:03/16/07
Author:Aaron Clinger
Classpath:org.casalib.time.Chain
File last modified:Monday, 01 December 2008, 13:34:40
Creates a chain of sequenced methods calls that wait for a specified event before continuing.
Example:
  • var boxMoveRight:PropertyTween = new PropertyTween(this.box_mc, "_x", com.robertpenner.easing.Bounce.easeOut, 400, 1.5);
    var boxMoveLeft:PropertyTween = new PropertyTween(this.box_mc, "_x", com.robertpenner.easing.Bounce.easeOut, 0, 1.5);
    
    var chain:Chain = new Chain(true);
    chain.addTask(this.boxMoveRight, "start", Tween.EVENT_COMPLETE);
    chain.addTask(this.boxMoveLeft, "start", Tween.EVENT_COMPLETE);
    chain.start();
Events broadcasted to listeners:
  • onStart = function (sender:Chain) {}
  • onStop = function (sender:Chain) {}
  • onResume = function (sender:Chain) {}
  • onComplete = function (sender:Chain) {}
  • onLoop = function (sender:Chain) {}

Summary


Constructor
  • Chain (isLooping:Boolean)
    • Creates a new chain.
Class properties
Instance methods
  • addTask (scope:DispatchableInterface, startMethodName:String, completeEventName:String, delay:Number, position:Number) : Void
    • Adds a task to the sequence.
  • removeTask (scope:Object, methodName:String) : Boolean
    • Removes task from the sequence.
  • start : Void
    • Starts the sequence from the beginning.
  • stop : Void
    • Stops the sequence at its current position.
  • resume : Void
    • Resumes sequence from stopped position or restarts the sequence from the beginning.
  • destroy : Void
    • Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.

Constructor

Chain

function Chain (
isLooping:Boolean)

Creates a new chain.
Parameters:
isLooping:
[optional] Indicates the sequence replays once completed true, or stops false; defaults to false.

Class properties

EVENT_COMPLETE

static EVENT_COMPLETE:String = 'onComplete'
(read,write)

EVENT_LOOP

static EVENT_LOOP:String = 'onLoop'
(read,write)

EVENT_RESUME

static EVENT_RESUME:String = 'onResume'
(read,write)

EVENT_START

static EVENT_START:String = 'onStart'
(read,write)

EVENT_STOP

static EVENT_STOP:String = 'onStop'
(read,write)

Instance methods

addTask

function addTask (
scope:DispatchableInterface, startMethodName:String, completeEventName:String, delay:Number, position:Number) : Void

Adds a task to the sequence.
Parameters:
scope :
An object that contains the method specified by "startMethodName" and that will dispatch "completeEventName" using org.casalib.event.EventDispatcher.
startMethodName :
A method that exists in the scope of the object specified by "scope".
completeEventName:
The event the class waits to receive before continuing.
delay :
The time in milliseconds between when the complete event was recieved until the next start method will be called.
position :
[optional] Specifies the index of the insertion in the sequence order; defaults to the next position.

destroy

function destroy (
) : Void

Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.

Always call
var boxMoveRight:PropertyTween = new PropertyTween(this.box_mc, "_x", com.robertpenner.easing.Bounce.easeOut, 400, 1.5);
var boxMoveLeft:PropertyTween = new PropertyTween(this.box_mc, "_x", com.robertpenner.easing.Bounce.easeOut, 0, 1.5);

var chain:Chain = new Chain(true);
chain.addTask(this.boxMoveRight, "start", Tween.EVENT_COMPLETE);
chain.addTask(this.boxMoveLeft, "start", Tween.EVENT_COMPLETE);
chain.start();
before deleting last object pointer.
#

removeTask

function removeTask (
scope:Object, methodName:String) : Boolean

Removes task from the sequence.
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".
Returns:
  • Returns true if task was successfully found and removed; otherwise false.

resume

function resume (
) : Void

Resumes sequence from stopped position or restarts the sequence from the beginning.
Events broadcasted to listeners:
  • onResume = function (sender:Chain) {}

start

function start (
) : Void

Starts the sequence from the beginning.
Events broadcasted to listeners:
  • onStart = function (sender:Chain) {}

stop

function stop (
) : Void

Stops the sequence at its current position.
Events broadcasted to listeners:
  • onStop = function (sender:Chain) {}