com.mosesSupposes.fuse.Fuse Class Reference

List of all members.

Detailed Description

The Fuse Kit [build1.1z3] Copyright (c) 2006 Moses Gunesch, MosesSupposes.com

Distributed under MIT Open Source License, see Fuse-Kit-License.html (in fuse package directory) Easing Equations (c) 2003 Robert Penner used by permission, see PennerEasing Visit http://www.mosessupposes.com/Fuse

Event & animation sequencer that extends Array.

To enable animation sequencing, pass Fuse to com.mosesSupposes.fuse.ZigoEngine#register or com.mosesSupposes.fuse.ZigoEngine#simpleSetup.

Events dispatched:


Unlike ZigoEngine which uses AsBroadcaster, Fuse uses the mx EventDispatcher standard.
var f:Fuse = new Fuse();
 f.addEventListener("onComplete", myListenerObj);

The Fuse utility is comprised of:
Fuse Object Syntax parameters are documented under the Fuse constructor.

Fuse Simple Syntax parameters are documented under Fuse.open.

Author:
Moses Gunesch / MosesSupposes.com
Version:
2.0

Definition at line 46 of file Fuse.as.

Public Member Functions

function addEventListener (event:String, handler:Object)
function removeEventListener (event:String, handler:Object)
function destroy ()
function get id ()
function get state ()
function get currentIndex ()
function get currentLabel ()
function get target ()
function set target (t:Object)
function addTarget (t:Object)
function removeTarget (t:Object)
function getActiveTargets (includeDefaults:Boolean)
function clone ()
function push ()
function pushTween (targets:Object, props:Object, pEnd:Object, seconds:Number, ease:Object, delay:Number, callback:Object)
function pop ()
function unshift ()
function shift ()
function splice (startIndex:Number, deleteCount:Number)
function slice (indexA:Number, indexB:Number)
function reverse ()
function traceItems (indexA:Number, indexB:Number)
function toString ()
function setStartProps (trueOrItemIDs:Object)
function start (setStart:Object)
function stop ()
function skipTo (indexOrLabel:Object)
function pause ()
function resume ()
function startItem (targs:Array, scope:Object)

Static Public Member Functions

static function simpleSetup ()
static function getInstance (idOrLabel:Object)
static function getInstances (stateFilter:String, targets:Object)
static function open (fuseOrID:Object)
static function openGroup (fuseOrID:Object)
static function closeGroup ()
static function close ()
static function closeAndStart (setStart:Object)
static function startRecent (setStart:Object)
static function addCommand (commandOrScope:Object, indexOrFunc:Object, argument:Object)
static function addBuildItem (args:Array)

Public Attributes

var label:String
var autoClear:Boolean = false
var scope:Object

Static Public Attributes

static var registryKey:String = 'fuse'
static var VERSION:String = FuseKitCommon.VERSION
static var OUTPUT_LEVEL:Number = 1
static var AUTOCLEAR:Boolean = false

Package Functions

function Fuse (action:Object)

Private Member Functions

function advance (wasTriggered:Boolean, silentStop:Boolean)
function playCurrentItem (postDelay:Boolean)
function evtSetStart (o:Object)

Static Private Member Functions

static function registerInstance (s:Fuse)
static function removeInstanceAt (id:Number, isDestroyCall:Boolean)

Private Attributes

var _nID:Number
var _nIndex:Number
var _sState:String = 'stopped'
var _aDefaultTargs:Array
var _nDelay:Number = -1
var _nTimeCache:Number = -1
var _oDel1:Object
var dispatchEvent:Function

Static Private Attributes

static var _aInstances:Array = null
static var _oBuildMode:Object = null


Constructor & Destructor Documentation

function com.mosesSupposes.fuse.Fuse.Fuse ( action:Object   )  [package]

Fuse extends Array to enable sequence-building & mangaement using familiar methods like push().

Parameters:
action One or more generic "action" objects or arrays in Fuse Object Syntax constituting a sequence.
 var f:Fuse = new Fuse(
  {start_x:'-50', start_xscale:150, start_alpha:0, seconds:.5 },
  [ 
   { width:500, ease:'easeInExpo', seconds:1 },
   { height:300, ease:'easeInOutExpo', delay:.5 }
  ]);
 f.target = box1_mc;
 f.start();
f.traceItems(); Outputs:
-Fuse#0 traceItems:
 ----------
 Fuse#0>Item#0: StartProps:[_alpha, _xscale, _x] Props:[_x, _xscale, _alpha]
 Fuse#0>Item#1: Props:[_height, _width]
 ----------

Fuse action objects may be:
Fuse action-object properties may be:
Fuse action-object values may be types:
Parseable action properties


Unless you have set FuseItem.ADD_UNDERSCORES to false, the following known properties are underscore-optional:
See also:
 target
 

 scope
 

 push
 

 pushTween
 

 open

Definition at line 307 of file Fuse.as.


Member Function Documentation

function com.mosesSupposes.fuse.Fuse.addEventListener ( event:String  ,
handler:Object   
)

This function is overwritten during EventDispatcher.initialize(). Add a listener for a particular event

Parameters:
event the name of the event ("onComplete", etc)
the function or object that should be called
See also:
removeEventListener

Definition at line 329 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.removeEventListener ( event:String  ,
handler:Object   
)

This function is overwritten during EventDispatcher.initialize(). Remove a listener for a particular event

Parameters:
event the name of the event ("onComplete", etc)
the function or object that should be called
See also:
addEventListener

Definition at line 339 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.destroy (  ) 

Deletes all variables and properties in the Fuse instance. You should remove all listeners before calling destroy(), then after the call delete any variable references to the instance cleared.

 myFuse.removeEventListener('onComplete',this);
 myFuse.destroy();
 delete myFuse;
 
See also:
autoClear

AUTOCLEAR

getInstance

Definition at line 354 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.simpleSetup (  )  [static]

Deprecated. Returns error from FuseKitCommon.

Deprecated:
Use new setup options: com.mosesSupposes.fuse.ZigoEngine#register or com.mosesSupposes.fuse.ZigoEngine#simpleSetup.

Definition at line 374 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.getInstance ( idOrLabel:Object   )  [static]

Instance-management: Gets a Fuse instance by its id or label This simple method returns one known Fuse instance. For more complex options use getInstances.

Parameters:
idOrLabel Fuse's numerical id or label identifying a unique Fuse instance.
Returns:
a Fuse instance if found or null if not
See also:
getInstances

Definition at line 383 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.getInstances ( stateFilter:String  ,
targets:Object   
) [static]

Instance-management: Get an array of some or all Fuse instances in active memory, with filtering options.

// get currently playing Fuses that handle the target my_mc
 var myMcFuses:Array = Fuse.getInstances("playing",my_mc);
 // get all the Fuses in active memory
 var fuses:Array = Fuse.getInstances();
Parameters:
stateFilter nothing/null/com.mosesSupposes.fuse.FuseKitCommon#ALL for all Fuse instances in active memory, or a play state "playing", "stopped" or "paused"
targets optional - a single target, an Array of targets, or a list of targets starting with the second param.
Returns:
an array containing one or more Fuse instances matching search criteria
See also:
getInstance

Definition at line 404 of file Fuse.as.

function get com.mosesSupposes.fuse.Fuse.id (  ) 

Instance default: an auto-assigned numerical reference

Returns:
Internal id based on instance count.
See also:
label

getInstance

Definition at line 441 of file Fuse.as.

function get com.mosesSupposes.fuse.Fuse.state (  ) 

Retrieves a Fuse instance's current play-state string.

Returns:
"stopped", "playing", or "paused"
See also:
currentIndex

Definition at line 448 of file Fuse.as.

function get com.mosesSupposes.fuse.Fuse.currentIndex (  ) 

Retrieves the current play-index of a Fuse instance.

Returns:
A number starting at 0 for the first action
See also:
state

currentLabel

Definition at line 456 of file Fuse.as.

function get com.mosesSupposes.fuse.Fuse.currentLabel (  ) 

Retrieves the currently playing action's label, if defined.

{ label:"introFade", start_alpha:0, start_brightOffset:100, time:1.5, ease:"easeInExpo" }
Returns:
A string set in the action object using the label property.
See also:
Fuse

label

state

currentIndex

Definition at line 467 of file Fuse.as.

function get com.mosesSupposes.fuse.Fuse.target (  ) 

see set target

Definition at line 473 of file Fuse.as.

function set com.mosesSupposes.fuse.Fuse.target ( t:Object   ) 

Instance default: Sets one or more animation targets that will be used for any actions that don't specify their own. Overwrites prior existing targets.

var f:Fuse = new Fuse();
 f.target = [clip1, clip2];
Parameters:
one target or an array of targets
Returns:
a single animation target if one is set or an Array of targets if more than one is set.
See also:
addTarget

removeTarget

getActiveTargets

Definition at line 486 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.addTarget ( t:Object   ) 

Adds to current default target list.

myFuse.addTarget(clip5);
Parameters:
accepts one or more targets, or an array of targets
See also:
target

removeTarget

getActiveTargets

Definition at line 501 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.removeTarget ( t:Object   ) 

Removes targets from the current default target list.

myFuse.removeTarget(clip5);
Parameters:
accepts one or more targets, or an array of targets
See also:
target

addTarget

getActiveTargets

Definition at line 525 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.getActiveTargets ( includeDefaults:Boolean   ) 

Gets both the default target list and any targets in the action currently being played.

Parameters:
includeDefaults If true is passed, list includes the Fuse instance's default target list plus active action targets.
Returns:
Array of targets currently being handled by the playing or paused action, plus the Fuse instance's default target list if true was passed.

If the Fuse instance queried is stopped, an empty array is returned.
See also:
target

addTarget

removeTarget

Definition at line 545 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.clone (  ) 

Returns a copy of Fuse as a new Fuse instance.

Returns:
new Fuse instance with default settings and actions.
See also:
push

pushTween

pop

unshift

shift

splice

slice

reverse

clone

Definition at line 571 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.push (  ) 

Pushes arguments into Fuse instance.

Returns:
new length of Fuse instance
See also:
pushTween

pop

unshift

shift

splice

slice

reverse

clone

Definition at line 596 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.pushTween ( targets:Object  ,
props:Object  ,
pEnd:Object  ,
seconds:Number  ,
ease:Object  ,
delay:Number  ,
callback:Object   
)

Lets you add an item to the Fuse in ZigoEngine.doTween() syntax. Pushes tween arguments into Fuse instance and accepts the same arguments as ZigoEngine.doTween().

Parameters:
targets tween target object or array of target objects
props tween property or Array of properties
pEnd tween end-value or Array of corresponding end-values
seconds tween duration
ease function, shortcut-string, or custom-easing-panel object
delay seconds to wait before performing the tween
callback function, string, or object
Returns:
new length of Fuse instance
See also:
com.mosesSupposes.fuse.ZigoEngine.doTween

push

pop

unshift

shift

splice

slice

reverse

clone

Definition at line 622 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.pop (  ) 

Removes last object placed into the Fuse instance.

Returns:
original object passed by user
See also:
push

pushTween

unshift

shift

splice

slice

reverse

clone

Definition at line 640 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.unshift (  ) 

Removes argument objects from Fuse instance.

Returns:
new length of Fuse instance
See also:
push

pushTween

pop

shift

splice

slice

reverse

clone

Definition at line 659 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.shift (  ) 

Shifts position of object in Fuse order.

Returns:
original object passed by user
See also:
push

pushTween

pop

unshift

splice

slice

reverse

clone

Definition at line 677 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.splice ( startIndex:Number  ,
deleteCount:Number   
)

Used to insert or remove items. Works almost exactly like Array.splice. Removed actions are destroyed permanently, with the exception of nested Fuses.

Parameters:
startIndex index in Fuse to begin removing objects
deleteCount number of objects to delete from startIndex
See also:
push

pushTween

pop

unshift

shift

slice

reverse

clone

Definition at line 697 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.slice ( indexA:Number  ,
indexB:Number   
)

Returns a new array instance consisting of a range of elements from the original array without modifying the original array. The array returned by this method includes the indexA element and all elements up to, but not including indexB element. If no parameters are passed, a duplicate of the original array is generated. For more information, see the Flash help explanation of Array.slice.

Parameters:
indexA:Number (optional) A number specifying the index of the starting point for the slice. If start is negative, the starting point begins at the end of the array, where -1 is the last element.
indexB:Number (optional) A number specifying the index of the ending point for the slice. If you omit this parameter, the slice includes all elements from the starting point to the last element of the array. If end is negative, the ending point is specified from the end of the array, where -1 is the last element.
Returns:
an array consisting of a range of elements from the original array.
See also:
push

pushTween

pop

unshift

shift

splice

reverse

clone

Definition at line 746 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.reverse (  ) 

Reverse the sequence of the Fuse

See also:
push

pushTween

pop

unshift

shift

splice

slice

clone

Definition at line 767 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.traceItems ( indexA:Number  ,
indexB:Number   
)

Traces specific or all objects contained within the fuse

Parameters:
indexA:Number (optional) A number specifying the index of the starting point for the slice. If start is negative, the starting point begins at the end of the array, where -1 is the last element.
indexB:Number (optional) - A number specifying the index of the ending point for the slice. If you omit this parameter, the slice includes all elements from the starting point to the last element of the array. If end is negative, the ending point is specified from the end of the array, where -1 is the last element.
See also:
toString

id

label

Definition at line 783 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.toString (  ) 

Returns:
a string representation of the fuse including its id, and label if defined.
See also:
traceItems

id

label

Definition at line 805 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.setStartProps ( trueOrItemIDs:Object   ) 

General: Presets start-properties like start_x in all or specific items. In this example a sequence is set up and all start props are set, although the Fuse may not be used until later.

var f:Fuse = new Fuse();
 f.target = clip1;
 f.push({ start_alpha:0 }); // fade up
 f.push({ x:'100', start_scale:150}); // scale down and slide
 f.setStartProps();
If you want to set start props as the Fuse is started, you can pass setStartProps parameters to start.
Parameters:
nothing/null/{@link com.mosesSupposes.fuse.FuseKitCommon.ALL} to set all start props in the Fuse. To specify some actions while excluding others, pass an array of item indices/labels or a series of indices/labels as separate parameters.
See also:
start

Definition at line 825 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.start ( setStart:Object   ) 

Play-control: Begins sequence play at index 0, with option to set start props prior to play. In this example all start props are set during start by passing true.

var f:Fuse = new Fuse();
 f.target = clip1;
 f.push({ start_alpha:0 }); // fade up
 f.push({ x:'100', start_scale:150}); // scale down and slide
 f.start(true);
Parameters:
setStart A setStartProps call is generated from all arguments before the Fuse begins playing.
See also:
stop

pause

resume

skipTo

Definition at line 851 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.stop (  ) 

Play-control: Stops a playing or paused Fuse instance and resets the play-index to 0.

See also:
start

pause

resume

skipTo

Definition at line 874 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.skipTo ( indexOrLabel:Object   ) 

Play-control: Starts Fuse at a particular index/label.

var f:Fuse = new Fuse();
 f.target = clip1;
 f.push({ start_alpha:0 });
 f.push({ x:'100', label:"slideRight"});
 //later...
 f.skipTo("slideRight"); // same as f.skipTo(1);
Parameters:
indexOrLabel numerical item index or label string. Pass a negative index to count back from end, like -1 for last item.
See also:
start

stop

pause

resume

Definition at line 914 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.pause (  ) 

Play-control: Pauses a playing Fuse instance and its running tweens. Waits for resume call to proceed.

See also:
start

stop

resume

skipTo

Definition at line 964 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.resume (  ) 

Resumes a paused Fuse instance and its animations. Attempts to correct for animations that have been disrupted during pause.

See also:
start

stop

pause

skipTo

Definition at line 986 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.advance ( wasTriggered:Boolean  ,
silentStop:Boolean   
) [private]

Internal handler called by items on completion.

Parameters:
wasTriggered is sent true when an item advanced prematurely using the trigger property completes and is used to track the final completion of a Fuse in which animations trail beyond the sequence end.
silentStop starting a 0-item Fuse triggers this param so that only the onComplete event gets fired.

Definition at line 1012 of file Fuse.as.

References complete().

Here is the call graph for this function:

function com.mosesSupposes.fuse.Fuse.playCurrentItem ( postDelay:Boolean   )  [private]

Internal helper that triggers startItem() in currently active item.

Parameters:
postDelay true is sent when a delay has completed.

Definition at line 1046 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.evtSetStart ( o:Object   )  [private]

Internal event used when the fuse is nested in a parent fuse. (Polymorphism - this is a FuseItem method that only appears in Fuse for the nested instance case).

Definition at line 1070 of file Fuse.as.

function com.mosesSupposes.fuse.Fuse.startItem ( targs:Array  ,
scope:Object   
)

FuseItem method used by a Fuse only when the it is nested in a parent Fuse.

Parameters:
targs 
scope 

Definition at line 1080 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.open ( fuseOrID:Object   )  [static]

Simple Syntax:Generate a new Fuse and begin intercepting tween calls until com.mosesSupposes.fuse.Fuse#close is called. Simple Syntax is an alternative way to construct Fuse sequences. Its primary uses are 1. Clear method-call sequencing and 2. An easy way for non-advanced coders to set up sequences.

 // Example 1: Can be used to enforce a clear, strict order of timed events
 Fuse.open();
  Fuse.addCommand (mainMenu, "draw", menuXML);
  Fuse.addCommand ("delay", .5);
  Fuse.addCommand (contentPage, "loadContent", firstItem);
  Fuse.addCommand (screenDisplay, "exposeLayout");
  Fuse.addCommand ("delay", 2);
  Fuse.addCommand (this, "onResize");
  Fuse.addCommand (Logger, "output", "Setup sequence complete.", 0);
 Fuse.close();

 // Example 2: Simple Syntax with shortcut tweens
 Fuse.open();
  box_mc.slideTo(150,150, 1);
  Fuse.openGroup();
   box_mc.scaleTo(250, 1);
   box_mc.brightnessTo(-50, 2);
  Fuse.closeGroup();
  box_mc.colorTo(0x6633FF, 1);
 Fuse.closeAndStart();
 

You may retrieve the Fuse instance created, or reopen an existing Fuse:
var f:Fuse = Fuse.open(); // store a reference to the Fuse
 // later...
 Fuse.open(f); // reopen existing
 // or...
 Fuse.open(0); // open Fuse with id 0
 // or...
 Fuse.open("introSequence"); // open Fuse with the label "introSequence"

If you mostly use simple syntax and don't reuse your Fuses, it's recommended that you set AUTOCLEAR to true to avoid memory buffering.
Parameters:
fuseOrID (Optional) Pass an existing Fuse, or its id or label to reopen it.
Returns:
The opened Fuse instance that tween calls will be routed to until close() is called.
See also:
openGroup

closeGroup

close

closeAndStart

startRecent

addCommand

id

label

Definition at line 1138 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.openGroup ( fuseOrID:Object   )  [static]

Simple Syntax: Begins a new animation group of simultaneous actions. If Fuse.openGroup() can be called in place of Fuse.open().

If Fuse.openGroup() is called while a previous group was open, the preceding group is closed automatically.

// use in place of Fuse.open() to begin a new Fuse.
 Fuse.openGroup();
  clip1.tween("_x","100");
  clip2.tween("_scale",200);
 Fuse.openGroup(); // you can skip closeGroup if opening another group.
  clip1.tween("_x","-100");
  clip2.tween("_scale",100);
 Fuse.closeAndStart(); // you can skip closeGroup here too.
 
Parameters:
fuseOrID:Fuse (Optional) an existing Fuse or Fuse's id or label in which to open the new group.
Returns:
The currently open fuse instance or a new Fuse if openGroup was called prior to open().
See also:
open

closeGroup

close

closeAndStart

startRecent

addCommand

id

label

Definition at line 1201 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.closeGroup (  )  [static]

Simple Syntax: Closes an action group started by openGroup. May be omitted if followed by Fuse.close or Fuse.closeAndStart.

If Fuse.openGroup() is called while a previous group was open, the preceding group is closed automatically and the closeGroup command can be skipped.

Fuse.open();
 clip1.tween("_x","100");
 Fuse.openGroup();
  clip1.tween("_x","-100");
  clip2.tween("_scale",200);
 Fuse.closeGroup();
 clip1.scaleTo(0);
 clip2.scaleTo(0);
 Fuse.closeAndStart();
See also:
open

openGroup

close

closeAndStart

startRecent

addCommand

Definition at line 1230 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.close (  )  [static]

Simple Syntax: Completes the Fuse generated by com.mosesSupposes.fuse.Fuse#open. It is important that you complete each Fuse created using Fuse.open() using either Fuse.close() or Fuse.closeAndStart(). You cannot call start on a Fuse instance while Fuse is open.

var runSetup:Fuse = Fuse.open();
 Fuse.addCommand(this, "callbackOne");
 Fuse.addCommand("delay", .25);
 Fuse.addCommand(this, "callbackTwo");
 Fuse.addCommand("delay", .25);
 Fuse.addCommand(this, "callbackThree");
 Fuse.close();

 // later in program...
 runSetup.start(); // reference the Fuse created
 
See also:
open

openGroup

closeGroup

closeAndStart

startRecent

addCommand

Definition at line 1258 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.closeAndStart ( setStart:Object   )  [static]

Simple Syntax: Close the open Fuse instance and start it playing.

var runSetup:Fuse = Fuse.open();
 clip1.fadeOut();
 clip2.fadeOut();
 clip3.fadeOut();
 Fuse.closeAndStart();
Parameters:
setStart A setStartProps call is generated from all arguments before the Fuse begins playing.
See also:
open

openGroup

closeGroup

close

startRecent

addCommand

Definition at line 1280 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.startRecent ( setStart:Object   )  [static]

Simple Syntax: Restarts the Fuse most recently created using Fuse.open().

Parameters:
setStart A setStartProps call is generated from all arguments before the Fuse begins playing.
See also:
open

openGroup

closeGroup

close

closeAndStart

addCommand

Definition at line 1298 of file Fuse.as.

static function com.mosesSupposes.fuse.Fuse.addCommand ( commandOrScope:Object  ,
indexOrFunc:Object  ,
argument:Object   
) [static]

Simple Syntax: Multi-purpose metho