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
- EVENT_START : String
- EVENT_STOP : String
- EVENT_RESUME : String
- EVENT_LOOP : String
- EVENT_COMPLETE : String
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.Instance methods inherited from EventDispatcherInstance methods inherited from CoreObject
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
# 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.
Overrides:
Specified by:
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; otherwisefalse
.
resume
function resume (
) : Void
Resumes sequence from stopped position or restarts the sequence from the beginning.
Events broadcasted to listeners:
onResume = function (sender:Chain) {}
Specified by:
start
function start (
) : Void
Starts the sequence from the beginning.
Events broadcasted to listeners:
onStart = function (sender:Chain) {}
Specified by:
stop
function stop (
) : Void
Stops the sequence at its current position.
Events broadcasted to listeners:
onStop = function (sender:Chain) {}
Specified by: