Main Page | Package | Index | Help

com.mosesSupposes.fuse

class Fuse

Array
  |
  +--com.mosesSupposes.fuse.Fuse


class Fuse
extends Array

Event & animation sequencer that extends Array.

Usage:
To enable animation sequencing, pass Fuse to ZigoEngine.register or ZigoEngine.simpleSetup.

Events dispatched:
  • onStart
  • onStop
  • onPause
  • onResume
  • onAdvance
  • onComplete

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:
  • Class & instance default settings
  • Array methods (see push)
  • Play-control methods (see start)
  • Simple Syntax static methods (see open)
  • A runtime Object Syntax interpreter (see Fuse)
  • Instance management methods (see getInstance)

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.1


Field Summary

public static
AUTOCLEAR: Boolean = false
Class default: whether Fuse instances are automatically destroyed after playing once unless otherwise specified by instance-level autoClear.

public static
AUTOSTOP: Boolean = true
Class default: whether Fuse instances stop when a tween is interrupted, or is destroyed if autoClear is turned on, unless otherwise specified by instance-level autoStop.

public static
OUTPUT_LEVEL: Number = 1
Class default: Controls how much feedback Fuse outputs, helpful for debugging.

public static
VERSION: String = FuseKitCommon.VERSION
Class default: Enables kit version to be retrieved at runtime or when reviewing a decompiled swf.

Property Summary

public
autoClear: Boolean
Instance default: Fuse instance is automatically destroyed after playing once.

public
autoStop: Boolean
Instance default: Fuse instance stops when any of its running tweens are interrupted, or is destroyed if autoClear is turned on.

public
currentIndex: Number (read-only)
Retrieves the current play-index of a Fuse instance.

public
currentLabel: String (read-only)
Retrieves the currently playing action's label, if defined.

public
duration: Number
Instance default: duration value in seconds for any action that does not specify one.
 
public
easing: Object
Instance default: easing value for any action that does not specify one.

public
id: Number (read-only)
Instance default: an auto-assigned numerical reference

public
label: String
Instance default: Convenience, allows you to name any Fuse.

public
scope: Object
Instance default: scope for all functions run from a Fuse if left unspecified within the action.

public
state: String (read-only)
Retrieves a Fuse instance's current play-state string.

public
target: Object (read, write)
Instance default: Sets one or more animation targets that will be used for any actions that don't specify their own.

Constructor


Fuse ( action: Object)
Fuse extends Array to enable sequence-building & management using familiar methods like push().

Method Summary

public static
addCommand ( commandOrScope: Object, indexOrFunc: Object, argument: Object ): Void
Simple Syntax: Multi-purpose method to add an inline Fuse command, delay, or function-call to the open Fuse.

public
addEventListener ( event: String, handler: Object ): Void
Add a listener for a particular event

public
addTarget ( t: Object ): Void
Adds to current default target list.

public
clone ( ): Fuse
Returns a copy of Fuse as a new Fuse instance.

public static
close ( ): Void
Simple Syntax: Completes the Fuse generated by open.

public static
closeAndStart ( setStart: Object ): Void
Simple Syntax: Close the open Fuse instance and start it playing.

public static
closeGroup ( ): Void
Simple Syntax: Closes an action group started by openGroup.

public
destroy ( ): Void
Deletes all variables and properties in the Fuse instance.

public
fastForward ( resumeAtIndexOrLabel: Object ): Void
Fast-forwards animations in some or all remaining actions.

public
getActiveTargets ( includeDefaults: Boolean ): Array
Gets both the default target list and any targets in the action currently being played.

public static
getInstance ( idOrLabel: Object ): Fuse
Instance-management: Gets a Fuse instance by its id or label

public static
getInstances ( stateFilter: String, targets: Object ): Array
Instance-management: Get an array of some or all Fuse instances in active memory, with filtering options.

public static
open ( fuseOrID: Object ): Fuse
Simple Syntax:Generate a new Fuse and begin intercepting tween calls until close is called.

public static
openGroup ( fuseOrID: Object ): Fuse
Simple Syntax: Begins a new animation group of simultaneous actions.

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

public
pop ( ): Object
Removes the first element from a Fuse and returns that action object.

public
push ( ): Number
Adds one or more elements to the end of a Fuse and returns the new length of the Fuse.

public
pushTween ( targets: Object, props: Object, endvals: Object, seconds: Number, ease: Object, delay: Number, callback: Object ): Number
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().

public
removeEventListener ( event: String, handler: Object ): Void
Remove a listener for a particular event

public
removeTarget ( t: Object ): Void
Removes targets from the current default target list.

public
resume ( ): Void
Resumes a paused Fuse instance and its animations. Attempts to correct for animations that have been disrupted during pause.

public
reverse ( ): Void
Reverse the sequence of the Fuse

public
setStartProps ( trueOrItemIDs: Object ): Void
General: Presets start-properties like start_x in all or specific items.

public
shift ( ): Object
Removes the first element from a Fuse and returns that action object.

public
skipTo ( indexOrLabel: Object ): Void
Play-control: Starts Fuse at a particular index/label.

public
slice ( indexA: Number, indexB: Number ): Array
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.

public
splice ( startIndex: Number, deleteCount: Number ): Void
Used to insert or remove items. Works almost exactly like Array.splice. Removed actions are destroyed permanently, with the exception of nested Fuses.

public
start ( setStart: Object ): Void
Play-control: Begins sequence play at index 0, with option to set start props prior to play.

public static
startRecent ( setStart: Object ): Void
Simple Syntax: Restarts the Fuse most recently created using Fuse.open().

public
stop ( ): Void
Play-control: Stops a playing or paused Fuse instance and resets the play-index to 0.

public
toString ( ): String


public
traceItems ( indexA: Number, indexB: Number ): Void
Traces specific or all objects contained within the fuse

public
unshift ( ): Number
Adds one or more elements to the beginning of a Fuse and returns the new length of the Fuse.



Field Documentation

autoClear

public var autoClear: Boolean
Instance default: Fuse instance is automatically destroyed after playing once.

Usage:
var f:Fuse = new Fuse();
f.autoClear = true;
In this example, the fuse instance f will delete itself after it plays through once, at which time you should also delete the variable f to prevent memory buffering issues.

AUTOCLEAR

public static var AUTOCLEAR: Boolean = false
Class default: whether Fuse instances are automatically destroyed after playing once unless otherwise specified by instance-level autoClear.

Usage:
// once only
Fuse.AUTOCLEAR = true;
 
// later this can be overridden in any instance
var f:Fuse = new Fuse();
f.autoClear = false;
When a Fuse is set to auto-remove itself it is best practice to not set a variable reference to that Fuse, which may cause memory buffering, or to delete the variable when the Fuse is complete.

To override this default on a per-Fuse basis set the instance's autoClear property.

autoStop

public var autoStop: Boolean
Instance default: Fuse instance stops when any of its running tweens are interrupted, or is destroyed if autoClear is turned on.

Usage:
This instance-level setting overrides the default setting Fuse.AUTOSTOP. If false an interrupted Fuse will recover and continue to play through.
var f:Fuse = new Fuse();
f.autoStop = false; //override the default setting for this Fuse instance

AUTOSTOP

public static var AUTOSTOP: Boolean = true
Class default: whether Fuse instances stop when a tween is interrupted, or is destroyed if autoClear is turned on, unless otherwise specified by instance-level autoStop.

Usage:
// once only
Fuse.AUTOSTOP = false;
If this default is set false, Fuses will skip past any externally interrupted tweens and continue to play through. When Fuses are used in interactive devices like rollover states, it is best to leave this setting true to avoid conflicts between Fuse instances controlling the same behavior.

Note that an interruption will not occur if new non-overlapping tweens are started on a clip that a Fuse is tweening. To enforce interruptions in such cases you can set ZigoEngine.com.mosesSupposes.ZigoEngine.AUTOSTOP to true, which causes all tweening properties in a clip to stop when a new tween is removed, or use ZigoEngine.com.mosesSupposes.ZigoEngine.removeTween prior to the call that may interrupt a Fuse.

To override this default on a per-Fuse basis set the instance's autoStop property.

duration

public var duration: Number
Instance default: duration value in seconds for any action that does not specify one.

Usage:
This setting supercedes the default ZigoEngine.DURATION only for the Fuse instance it is set on, and is overrided by any action containing its own seconds, duration, or time parameter.
var f:Fuse = new Fuse();
f.duration = 2;
f.push({ x:'100' }); // adopts new default
f.push({ y:'100', time:.5 }); // overrides default

easing

public var easing: Object
Instance default: easing value for any action that does not specify one.

Usage:
This setting supercedes the default ZigoEngine.EASING only for the Fuse instance it is set on, and is overrided by any action containing its own ease or easing parameter.
var f:Fuse = new Fuse();
f.easing = "easeInOutCubic";
f.push({ x:'100' }); // adopts new default
f.push({ y:'100', ease:'easeInExpo' }); // overrides default

label

public var label: String
Instance default: Convenience, allows you to name any Fuse.

The Fuse label is used in output messages, and can be used to reference a Fuse instance in getInstance, fastForward and Simple Syntax methods open and openGroup.

Usage:
var drawContentPage:Fuse = new Fuse();
drawContentPage.label = "drawContentPage";

OUTPUT_LEVEL

public static var OUTPUT_LEVEL: Number = 1
Class default: Controls how much feedback Fuse outputs, helpful for debugging.

Usage:
// once only
Fuse.OUTPUT_LEVEL = 3;
  • 0 = no traces,
  • 1 = normal errors & warnings
  • 2 = additional Fuse output
  • 3 = additional FuseItem output

scope

public var scope: Object
Instance default: scope for all functions run from a Fuse if left unspecified within the action.

Usage:
var f:Fuse = new Fuse();
f.scope = this;
f.push({target:menu, 
	start_alpha:0,
	x:getMenuX,
	y:getMenuY, 
	startfunc:"setupMenu", 
	updfunc:"onMenuFadeUpdate", 
	func:"onMenuShown"
});
f.push({ scope:contentArea,
	func:"drawContent"
});
In this example, all the functions in the first action, including the runtime-evaluation calls to supposed getMenuX and getMenuY methods will be auto-scoped to the Fuse's default scope (this). In the second action, drawContent is specifically scoped to the contentArea object, overriding the default. It's most useful to set a default scope when there will be many function calls within the sequence, to save you from specifically scoping each action.

VERSION

public static var VERSION: String = FuseKitCommon.VERSION
Class default: Enables kit version to be retrieved at runtime or when reviewing a decompiled swf.

Usage:
trace(Fuse.VERSION); // if the version is incorrect, clear your ASO cache.


Property Documentation

currentIndex

public currentIndex : Number (read-only)
Retrieves the current play-index of a Fuse instance.

Value:
A number starting at 0 for the first action

See also:

currentLabel

public currentLabel : String (read-only)
Retrieves the currently playing action's label, if defined.

{ label:"introFade", start_alpha:0, start_brightOffset:100, time:1.5, ease:"easeInExpo" }

Value:
A string set in the action object using the label property.

See also:

id

public id : Number (read-only)
Instance default: an auto-assigned numerical reference

Value:
Internal id based on instance count.

See also:

state

public state : String (read-only)
Retrieves a Fuse instance's current play-state string.

Value:
"stopped", "playing", or "paused"

See also:

target

public target : Object (read, write)
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];

Value:
a single animation target if one is set or an Array of targets if more than one is set.

See also:


Constructor Documentation

Fuse

function Fuse (fuseAction:Object [, fuseAction:Object, etc...])
Fuse extends Array to enable sequence-building & management using familiar methods like push().

Usage:
// setup - once per FLA only
import com.mosesSupposes.fuse.*;
ZigoEngine.register( Fuse, PennerEasing );

// build a short intro sequence to apply to box1_mc.
var f:Fuse = new Fuse();
f.label = "swoopyIntro";
f.target = box1_mc;

f.push({ delay: .25 });

// labels can be used in some methods but are mostly a convenience.
f.push({ label: "appear",
         start_scale: 500,
         start_alpha: 0,
         time: 1.75,
         ease: "easeOutBack",
         trigger: .5 // advances this action early
        });


// the array brackets in this action form a group of parallel tweens
f.push([ 
        { label: "swoop",
          x: "80",
          controlY: "50", // adds a bezier curve
          time: 1.5,
          ease: "easeInOutBack"
         },
          
        // these tweens bounce back, by using 2 cycles
        { brightOffset: 50,
          rotation: 10,
          ease: "easeInOutQuad",
          cycles: 2,
          time: .5,
          delay: .25 
        }
       ]);

// a simple callback. You could also subscribe to the "onComplete" event.
f.push({ func:"trace", args:"done!" });

f.traceItems();
f.start(true); // passing true presets start props - remove it to see a change.
Starts the Fuse and outputs:
-Fuse "swoopyIntro" traceItems:
----------
-Fuse "swoopyIntro">Item #0: Elements:[delay]
-Fuse "swoopyIntro">Item #1 "appear": Elements:[trigger] StartProps:[_alpha, _scale] Props:[_scale, _alpha]
-Fuse "swoopyIntro">Item #2 "swoop": Props:[_brightOffset, _rotation, _bezier_]
-Fuse "swoopyIntro">Item #3: Elements:[callback]
----------
done!
Once a Fuse Array contains at least one action it is controllable with the play methods start, stop, pause, resume, skipTo, and fastForward. Fuses dispatch the events listed at the top of this page during their play cycle. Start properties can be preset for all or a specific subset of actions, using the setStartProps method or during any start call. (If true were not passed during start in the example above, the target would be visible during the short delay in the first action.) Note that end values are omitted in the "appear" action, making use of Fuse's smart parsing to keep actions concise. Actions can be further condensed with the use of instance defaults duration, easing, target, and scope.

The power of Object Syntax is structural. It in fact has few parameters of its own — label, target/addTarget, event/eventparams, trigger, command and a few extra time-notation options. Standard ZigoEngine tweening parameters, including user-defined variables, make up the bulk of what you'll see listed in any action. You can expect Object Syntax's features to be logical, intuitive and useful.

± Getting started with Object Syntax

± Object Syntax Mechanics (advanced topic)

± Working with asynchronous events (advanced topic)


Object Syntax Detail

Fuse action objects may be:
  • Generic objects containing parseable properties
    { target:clip1, x:10, seconds:2, ease:Strong.easeInOut }
  • An array of such action objects which creates a simultaneous tween Group
    [ { x:10, seconds:2, ease:Strong.easeInOut }, { start_alpha:0, seconds:.5 } ]
  • A nested Fuse which will play as an action
    myFuse2

    Fuse supports an unlimited level of nesting - for instance myFuse2 can contain & run myFuse3 which contains and runs myFuse4 and so on.

    Nested Fuses many not appear within groups (the Array syntax in the previous point). However it is quite possible to start secondary Fuses from any action or action group with commands like { scope:myFuse2, func:"start" }. See a more complex example of this below under the command parameter.
  • "Applied actions": a special format for reusing actions by including an action property.

    For example if an action var intro:Object = { ... } has been defined, you can then include it in later Fuse actions like this:
    { target:clip1, action:intro }

    This lets you build multi-purpose behaviors that can be used with different targets, perhaps a custom fade or movement effect.
    Applied actions may contain the following properties that modify the base action: delay, target, addTarget, label, trigger.
    While target overrides, addTarget concatenates targets with any that are defined in the action. See below for info on other properties.

    Applied actions may be included in groups; the action property can also be an array itself. Note that "runtime evaluation" (below) is not supported with the action property itself, although sub-properties in the applied action may make use of that feature.

Fuse action-object properties may be:
  • Parseable properties, listed below
  • Any custom property you wish to tween (should be pre-declared and set to a number)
  • Start values: Prepend start_ to any property and it will be set prior to tweening.
  • Omitted: Fuse's smart parsing allows you to avoid needing a start and end value for every property. When a start value is omitted, the property's current value is used as in ZigoEngine. When a start-value is included but the end value is omitted, Fuse inserts an end value in one of two ways:
    • Natural reset: Known properties with a natural reset value like _rotation:0, _alpha:100, _brightOffset:0, etc., auto-fill the end value as such. For example a fade-in effect can be generated with the simple action {start_alpha:0} which will tween to 100 automatically.
    • Open properties: Props like _x or _width that do not have a natural reset are auto-filled to their value prior to the tween. In this action a clip will be moved offscreen then slide back to its current location: { start_x:-100, start_y:-100 }.

Fuse action-object values may be types:
  • Number - a tween's end position. x:100
  • String - calculate tween using relative positioning.
    Example: rotation:"-90" yields a counter-clockwise rotation.
  • Boolean values, set at start or end of tween.
    Example: start_visible:true
  • Tint values can be Number (0x000000), String ("#000000"), or null (reset)
    Example: tint:"#FF3300"
  • Time is specified in seconds, and may be Number or timecode-String format.
    Examples: seconds:2, startAt:"01:75" - timecode for a 1.75-second delay
  • Function - (Advanced) "Runtime evaluation" - function is queried as the action is played in the sequence. Functions should return values appropriate to the property.
    Example: { x:function(){ return _root._xmouse; } }

    This is a powerful feature that helps eliminate the need to hardcode values in advance. Fuses can be written to be "live", querying for targets and values themselves by retrieving state variables from within your program.

    Such functions will be scoped first to the action then the Fuse instance's scope property. If scope is already being used for callbacks, you can use a Delegate to individually scope runtime-evaluation functions.
  • Multi-value Object or Array - (Advanced) A new feature is the ability to directly tween multiple values in an Object or Array. Note that like any custom variables these objects must exist prior to tweening and have their properties set to numerical values in advance.
    Examples: { myArray:[10,20], myMatrix:{a:0, b:1, tx:100}, GradientBevel_colors:[0xFF0000, 0x333333, 0x00FFFF] }
  • Colors Array - (Advanced) Tweening a generic array of color values can help with situations like tweening the properties of a gradient fill that's redrawn on tween update. Any array whose name contains 'colors' (case is ignored) will be handled by the engine as an array of color values. Note that the internal colortransforms are not applied to any target, simply updated within the array.
    Example: { myColors: [ 0x000000, 0xFFFFFF ], scope:this, updfunc:'redrawGradient' }

Parseable properties:
  • label An action's string id, used for skipTo and fastForward. Groups are considered single actions by Fuse. (To label a group include a label within any of its sub-actions.) As a convenience, labels also appear in output messages.
  • target Animation target or Array of targets. Overrides the instance's default target list.
  • addTarget Concatenates one or an Array of targets with the default target list.
  • ease or easing Accepts same formats as ZigoEngine.doTween's easing parameter.
  • seconds, time or duration See time formatting above.
  • delay or startAt See time formatting above.
  • event String declaring a custom event that should be dispatched by the engine.
    Subscribe to this custom event on the Fuse instance the same as you would for built-in events (see header).

 

  • func Function, string name of function, or Easyfunc string like "myClip.doSomething(true);" (Shortcuts must be registered to use the easyfunc feature.)
  • scope Object - overrides instance default scope. Note that in Fuse actions this property is special in that it will be applied to all callbacks or runtime-evaluation functions if not otherwise defined.
  • args One argument or an array of arguments to pass to the func callback.
  • startfunc Callback fired after any delay and as tween is starting. Supports various formats - see func above.
  • startscope If not defined, the scope property or instance default scope will be used.
  • startargs One argument or an array of arguments to pass to the startfunc callback.
  • updfunc Callback fired on engine pulse as the tweens in the action are updated. Accepts various formats - see func above.
  • updscope If not defined, the scope property or instance default scope will be used.
  • updargs One argument or an array of arguments to pass to the updfunc callback.
  • extra1 Optional fifth parameter sent to easing method. Elastic easing amplitude or Back easing overshoot.
  • extra2 Optional sixth parameter sent to easing method. Elastic easing period.
  • _bezier_ (Not necessary, see controlX, controlY below.) Generic object with some or all of the properties {x:,y:,controlX:,controlY:}. Relative (string) values are okay. Note that only one control param is necessary to generate a curved motion path.
  • controlX, controlY Including one or both of these parameters in a Fuse action along with x and/or y generates a bezier curve similar to using the _bezier_ property but without the need for a nested object.
  • cycles An integer 2 or higher, tweens back and forth between start and end positions. Infinite cycles (0 or "LOOP" in ZigoEngine.doTween) are not allowed in Fuses.
  • roundResults Overrides the class setting ZigoEngine.ROUND_RESULTS for an individual action. Useful for instance, if the class default is true but you need to execute a tween such as DropShadow_alpha which requires a 0-1 range.
  • skipLevel 0,1, or 2. An advanced behavior setting for cases where tweens fail. See ZigoEngine.SKIP_LEVEL for details. In Fuse, this parameter also applies to the custom event parameter, although standard Fuse events like onComplete are not skipped.
  • trigger May be set as seconds (see time formatting above) or set to true if in a group to indicate advance after the item trigger is grouped with.
    Advances the sequence prior to action completion. This is a powerful feature that makes sequencing far less rigid and more timeline-like.
    Example 1: In this group the sequence advances after the fade action. [ { start_alpha:0, seconds:.5, trigger:true}, { x:'100', seconds:3 } ]
    Example 2: Here the sequence advances after 1.5 seconds, while the action takes 3 seconds. { width:500, delay:1, seconds:2, trigger:1.5 }

    Note that the onComplete Fuse event is not fired until any trailing tweens from triggered actions finish.
  • command String "start","stop","pause","resume","skipTo", or "setStartProps".
    Allows actions to control Fuse play.
    Example: a final action of {command:"start"} causes the Fuse to loop.
    Commands should be separate actions. They may not appear within action groups or be blocked with tweens or callbacks.
    Actions containing a command property may ONLY contain the additional properties: scope, args, label, delay.
    Note that any arguments in args are sent to the Fuse command, and scope is only used for runtime-evaluation of other params set to function (see "Runtime-evaluation" above).

    Examples of a command with an argument: { command:"skipTo", args:3 }, { command:"start", args:true }
  • easyfunc Removed from kit. func, startfunc, updfunc parameters now accept easyfunc strings (see func above).
(Advanced) The following example illustrates how command actions can be used in more complex arrangements. Here a complex group of Fuses is associated by controlling each other, without the use of nested Fuses.
var fuseA:Fuse = new Fuse();
var fuseB:Fuse = new Fuse();
var fuseC:Fuse = new Fuse();
// .. build Fuses here then..
// final action in fuseC will resume the master Fuse,
fuseC.push({ scope:fuseA, func:"resume" });
// .. somewhere in fuseA, begin the others & pause:
fuseA.push([{scope:fuseB, func:"start"},
				 {scope:fuseC, func:"start"} ]);
fuseA.push({ command:"pause" }); // keep command in a separate action
// .. continue pushing actions into fuseA here.
// .. fuseA will resume when fuseC hits its final "resume" action.

Unless you have set FuseItem.ADD_UNDERSCORES to false, your Fuse actions may optionally omit underscores for the known properties below, listed here without. For descriptions of ZigoEngine properties (shown in bold), look up their underscored counterparts in ZigoEngine.doTween.
  • alpha
  • brightOffset
  • brightness
  • colorReset
  • colorTransform
  • contrast
  • fade
  • frame
  • height
  • invertColor
  • rotation
  • scale
  • size
  • tint
  • tintPercent
  • visible
  • width
  • x
  • xscale
  • y
  • yscale

Parameters:
fuseAction
One or more generic "action" objects or arrays in Fuse Object Syntax constituting a sequence.
See also:


Method Documentation

addCommand

public static function addCommand (commandOrScope: Object,
 indexOrFunc: Object,
 argument: Object): Void

Multi-purpose method for all non-animation Simple Syntax features.

Usage

var f:Fuse = new Fuse();
 
// callback: scope, func, args
Fuse.addCommand(this, "setItemData", 0, "Submit", true);
 
// delay
Fuse.addCommand("delay", .5);
 
// inline Fuse play-command: 
// this final action will cause the Fuse to loop
Fuse.addCommand("start");
 
// advance-trigger (should appear within group)
Fuse.addCommand("trigger", .5);

Some addCommand calls are allowed inside groups ('delay','trigger', function-calls), but most are not. For instance if you want to have a Fuse pause itself, place the command Fuse.addCommand('pause'); outside any Fuse.openGroup(); blocks.

The 'trigger' feature should appear within groups and adds powerful flexibility for animators:

Just as delays can stagger the start times of grouped tweens, triggers allow the ends of grouped animations to overlap with the following action by advancing the action early. For example if an action contains two tweens, the longest of which is 2 seconds plus a 1-second delay, including Fuse.addCommand("trigger", 2.5); in the group would advance the Fuse to the next action half a second before the running tweens complete. This adds timeline-like flexibility and helps you keep your sequences less rigid.

Parameters:
commandOrScope
Accepts: 'delay','trigger','start','stop','pause','resume','skipTo','setStartProps' or in the case of a function-call a scope such as this.
indexOrFunc
Varies based on first argument: 'delay', 'trigger' : Number of seconds. 'skipTo': Destination index (starting at 0 for the first action). For function-call, a string of the function name such as 'trace'.
argument
Function-call: Any number of arguments can follow and will be passed during the call.
See also:

addEventListener

public function addEventListener (event: String,
 handler: Object): Void
Add a listener for a particular event

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

addTarget

public function addTarget (t: Object): Void
Adds to current default target list.

myFuse.addTarget(clip5);

Parameters:
t
accepts one or more targets, or an array of targets
See also:

clone

public function clone (): Fuse
Returns a copy of Fuse as a new Fuse instance.

Returns:
new Fuse instance with default settings and actions.

See also:

close

public static function close (): Void
Simple Syntax: Completes the Fuse generated by 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:

closeAndStart

public static function closeAndStart (setStart: Object): Void
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:

closeGroup

public static function closeGroup (): Void
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:

destroy

public function destroy (): Void
Deletes all variables and properties in the Fuse instance.

Usage:
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:

fastForward

public function fastForward (resumeAtIndexOrLabel: Object): Void
Fast-forwards animations in some or all remaining actions.

Behavior:
  • Calling with no arguments: Fast-forwards all remaining animation in the Fuse. The onComplete event is fired.
  • Passing a positive or negative integer or string: Fast-forwards up to, then resumes play at the index specified. Negative integer counts back from last item, string locates an action or nested Fuse by its label property.
  • Callbacks and events are disregarded during fast-forwarding.
  • If you pass 0 or an index that has already played, a warning is thrown and skipTo is called instead.
  • Note that when passing a label string, nested Fuse instance labels are scanned but not action labels within nested Fuses. To fast-forward to a specific point in a nested Fuse, first call fastForward to advance to the primary Fuse, then a second time on the secondary Fuse.
  • Fuse does not include any similar animation-rewinding method, which would not be practical for a number of reasons within its current architecture.

Usage:
// fast-forward all animations and end fuse:
myFuse.fastForward();
 
// fast-forward from current index and resume play at index 8
myFuse.fastForward(8);
 
// fast-forward then resume at a labeled action like { x:"100", label:"slider" }
myFuse.fastForward("slider");
 
// fast-forward but play final action
myFuse.fastForward(-1);
The following example demonstrates fast-forwarding to an index within a nested Fuse instance, and also shows how a nested Fuse's label property can be used to fast-forward to. Note that the fast-forward commands could alternatively be written using positive or negative integers as in the examplese above.
var nestedFuse1:Fuse = new Fuse(
	{ rotation:180, label:"spin" },
	{ tint:0x33FF00, tintPercent:50, label:"tint" }
);
nestedFuse1.label = "NF1";
nestedFuse1.target = clip1_mc;
 
var mainFuse:Fuse = new Fuse(
	{ x:"100", label:"slideRight" },
	nestedFuse1,
	{ x:"-100", label:"slideLeft" }
);
mainFuse.target = clip1_mc;
mainFuse.start();
 
// fast-forward to the "tint" action by using two fastForward calls.
mainFuse.fastForward("NF1"); // first jump to the nested Fuse using its label
nestedFuse1.fastForward("tint"); // then jump to the tint action using its label

Parameters:
resumeAtIndexOrLabel
Numerical item index or label string to fast-forward up to and resume playing at.
See also:

getActiveTargets

public function getActiveTargets (includeDefaults: Boolean): Array
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:

getInstance

public static function getInstance (idOrLabel: Object): Fuse
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

public static function getInstances (stateFilter: String,
 targets: Object): Array
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/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:

open

public static function open (fuseOrID: Object): Fuse
Simple Syntax:Generate a new Fuse and begin intercepting tween calls until 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.

Usage:
// 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

public static function openGroup (fuseOrID: Object): Fuse
Simple Syntax: Begins a new animation group of simultaneous actions.

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
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:

pause

public function pause (): Void
Play-control: Pauses a playing Fuse instance and its running tweens. Waits for resume call to proceed.

See also:

pop

public function pop (): Object
Removes the first element from a Fuse and returns that action object.

Returns:
original object passed by user

See also:

push

public function push (fuseAction:Object [, fuseAction:Object, etc...]): Number
Adds one or more elements to the end of a Fuse and returns the new length of the Fuse.
Usage:
myFuse.push({ x:"100" }); // add an action to the end of the sequence
Parameters:
fuseAction
One or more generic "action" objects or arrays in Fuse Object Syntax starting at this argument
Returns:
new length of Fuse instance

See also:

pushTween

public function pushTween (targets: Object,
 props: Object,
 endvals: Object,
 seconds: Number,
 ease: Object,
 delay: Number,
 callback: Object): Number
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
endvals
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:

removeEventListener

public function removeEventListener (event: String,
 handler: Object): Void
Remove a listener for a particular event

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

removeTarget

public function removeTarget (t: Object): Void
Removes targets from the current default target list.

myFuse.removeTarget(clip5);

Parameters:
t
accepts one or more targets, or an array of targets
See also:

resume

public function resume (): Void
Resumes a paused Fuse instance and its animations. Attempts to correct for animations that have been disrupted during pause.

See also:

reverse

public function reverse (): Void
Reverse the sequence of the Fuse

See also:

setStartProps

public function setStartProps (trueOrItemIDs: Object): Void
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:
trueOrItemIDs
nothing/null/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:

shift

public function shift (): Object
Removes the first element from a Fuse and returns that action object.

Returns:
original object passed by user

See also:

skipTo

public function skipTo (indexOrLabel: Object): Void
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:

slice

public function slice (indexA: Number,
 indexB: Number): Array
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
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
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:

splice

public function splice (startIndex: Number,
deleteCount: Number,
fuseAction:Object [, fuseAction:Object, etc...]): Void
Used to insert or remove items. Works almost exactly like Array.splice. Removed actions are destroyed permanently, with the exception of nested Fuses.
Usage:
myFuse.splice(0, 2); // remove two items from the beginning of the sequence
myFuse.splice(-2, 0, { x:"100" }); // insert an action two steps from the end of the sequence
Parameters:
startIndex
index in Fuse to begin removing objects
deleteCount
number of objects to delete from startIndex
fuseAction
One or more generic "action" objects or arrays in Fuse Object Syntax starting at this argument
See also:

start

public function start (setStart: Object): Void
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:

startRecent

public static function startRecent (setStart: Object): Void
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:

stop

public function stop (): Void
Play-control: Stops a playing or paused Fuse instance and resets the play-index to 0.

See also:

toString

public function toString (): String
Returns:
a string representation of the fuse including its id, and label if defined.

See also:

traceItems

public function traceItems (indexA: Number,
 indexB: Number): Void
Traces specific or all objects contained within the fuse

Parameters:
indexA
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
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:

unshift

public function unshift (fuseAction:Object [, fuseAction:Object, etc...]): Number
Adds one or more elements to the beginning of a Fuse and returns the new length of the Fuse.
Usage:
myFuse.unshift({ x:"100" }); // add an action to the beginning of the sequence
Parameters:
fuseAction
One or more generic "action" objects or arrays in Fuse Object Syntax starting at this argument
Returns:
new length of Fuse instance

See also:


The documentation was generated from the following file:


Generated on 1/14/2007 11:31:53 PM