![]() | ![]() |
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:
onStartonStoponPauseonResumeonAdvanceonCompletevar f:Fuse = new Fuse();
f.addEventListener("onComplete", myListenerObj);
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 |
| function com.mosesSupposes.fuse.Fuse.Fuse | ( | action:Object | ) | [package] |
Fuse extends Array to enable sequence-building & mangaement using familiar methods like push().
| 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(); |
-Fuse#0 traceItems: ---------- Fuse#0>Item#0: StartProps:[_alpha, _xscale, _x] Props:[_x, _xscale, _alpha] Fuse#0>Item#1: Props:[_height, _width] ----------
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
"Applied actions": a special format for reusing actions by including anactionproperty.
For example if an actionvar 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.
Whiletargetoverrides,addTargetconcatenates targets with any that are defined in the action. See below for info on others.
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.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"), ornull(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'sscopeproperty. Ifscopeis already being used for callbacks, you can use a Delegate to individually scope runtime-evaluation functions.
label String naming the action, that may be used during skipTo and viewed in output messages. (This property cannot be set to a function value)
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 com.mosesSupposes.fuse.ZigoEngine#doTween's easing parameter.
seconds, time or duration See time formatting above.
delay or startAt See time formatting above.
eventString 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).
eventparamsAn object whose properties will be copied to the event object dispatched with the custom event. (Requires that theeventproperty is defined)
func Function or string name of function
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.
argsOne argument or an array of arguments to pass to thefunccallback.
startfunc Callback fired after any delay and as tween is starting.
startscopeIf not defined, thescopeproperty or instance default scope will be used.
startargsOne argument or an array of arguments to pass to thestartfunccallback.
updfunc Callback fired on engine pulse as the tweens in the action are updated.
updscopeIf not defined, thescopeproperty or instance default scope will be used.
updargsOne argument or an array of arguments to pass to theupdfunccallback.
easyfuncString like"myClip.doSomething(true);". (com.mosesSupposes.fuse.Shortcuts must be registered to use this feature)
extra1 Elastic easing amplitude or Back easing overshoot
extra2 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 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 com.mosesSupposes.fuse.ZigoEngine#doTween) are not allowed in Fuses.
skipLevel0,1, or 2. See com.mosesSupposes.fuse.ZigoEngine#SKIP_LEVEL for details. In Fuse, this parameter also applies to the customeventparameter, although standard Fuse events likeonCompleteare not skipped.
triggerMay be set as seconds (see time formatting above) or set totrueif 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 theonCompleteFuse event is not fired until any trailing tweens from triggered actions finish.
commandString"start","stop","pause","resume","skipTo","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 acommandproperty may ONLY contain the additional properties:scope, args, label, delay.
Note that any arguments inargsare sent to the Fuse command, andscopeis only used for runtime-evaluation of other params set to function (see "Runtime-evaluation" above).
FuseItem.ADD_UNDERSCORES to false, the following known properties are underscore-optional: _alpha or alpha
_rotation or rotation
_x or x
_y or y
_xscale or xscale
_yscale or yscale
_scale or scale Sets _xscale and _yscale to the same value
_width or width
_height or height
_size or size Sets _width and _height to the same value
_frame or frame Tweens a MovieClip's timeline to a frame using easing specified.
_tint or tintTint formats above or object{tint:Number/null/hexString, percent:Number/String}.
_tintPercent or tintPercent Value range 0-100
_brightness or brightness Value range 0-100
_brightOffset or brightOffset Burn effect. -100=black, 0=normal, 100=white
_invertColor or invertColor Value range 0-100
_colorReset or colorReset Value ranges from 0 (current tint) to 100 (full reset).
_contrast or contrast 0=gray, 100=normal, 200=high-contrast, higher=posterized
_colorTransform or colorTransformFlash7 transform object{ra:,rb:,etc.}
_visible or visible
| function com.mosesSupposes.fuse.Fuse.addEventListener | ( | event:String | , | |
| handler:Object | ||||
| ) |
This function is overwritten during EventDispatcher.initialize(). Add a listener for a particular event
| event | the name of the event ("onComplete", etc) | |
| the | function or object that should be called |
| function com.mosesSupposes.fuse.Fuse.removeEventListener | ( | event:String | , | |
| handler:Object | ||||
| ) |
This function is overwritten during EventDispatcher.initialize(). Remove a listener for a particular event
| event | the name of the event ("onComplete", etc) | |
| the | function or object that should be called |
| function com.mosesSupposes.fuse.Fuse.destroy | ( | ) |
| static function com.mosesSupposes.fuse.Fuse.simpleSetup | ( | ) | [static] |
Deprecated. Returns error from FuseKitCommon.
| 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.
| 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();
| 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. |
| function get com.mosesSupposes.fuse.Fuse.id | ( | ) |
Instance default: an auto-assigned numerical reference
| function get com.mosesSupposes.fuse.Fuse.state | ( | ) |
Retrieves a Fuse instance's current play-state string.
"stopped", "playing", or "paused" | function get com.mosesSupposes.fuse.Fuse.currentIndex | ( | ) |
| function get com.mosesSupposes.fuse.Fuse.currentLabel | ( | ) |
| function get com.mosesSupposes.fuse.Fuse.target | ( | ) |
| 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];
| one | target or an array of targets |
| function com.mosesSupposes.fuse.Fuse.addTarget | ( | t:Object | ) |
Adds to current default target list.
myFuse.addTarget(clip5);
| accepts | one or more targets, or an array of targets |
| function com.mosesSupposes.fuse.Fuse.removeTarget | ( | t:Object | ) |
Removes targets from the current default target list.
myFuse.removeTarget(clip5);
| accepts | one or more targets, or an array of targets |
| function com.mosesSupposes.fuse.Fuse.getActiveTargets | ( | includeDefaults:Boolean | ) |
Gets both the default target list and any targets in the action currently being played.
| includeDefaults | If true is passed, list includes the Fuse instance's default target list plus active action targets. |
| function com.mosesSupposes.fuse.Fuse.clone | ( | ) |
| function com.mosesSupposes.fuse.Fuse.push | ( | ) |
| 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().
| 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 |
| function com.mosesSupposes.fuse.Fuse.pop | ( | ) |
| function com.mosesSupposes.fuse.Fuse.unshift | ( | ) |
| function com.mosesSupposes.fuse.Fuse.shift | ( | ) |
| 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.
| startIndex | index in Fuse to begin removing objects | |
| deleteCount | number of objects to delete from startIndex |
| 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.
| 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. |
| function com.mosesSupposes.fuse.Fuse.reverse | ( | ) |
| function com.mosesSupposes.fuse.Fuse.traceItems | ( | indexA:Number | , | |
| indexB:Number | ||||
| ) |
Traces specific or all objects contained within the fuse
| 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. |
| function com.mosesSupposes.fuse.Fuse.toString | ( | ) |
| 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. | 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. |
| 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);
| setStart | A setStartProps call is generated from all arguments before the Fuse begins playing. |
| function com.mosesSupposes.fuse.Fuse.stop | ( | ) |
| 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);
| indexOrLabel | numerical item index or label string. Pass a negative index to count back from end, like -1 for last item. |
| function com.mosesSupposes.fuse.Fuse.pause | ( | ) |
| function com.mosesSupposes.fuse.Fuse.resume | ( | ) |
| function com.mosesSupposes.fuse.Fuse.advance | ( | wasTriggered:Boolean | , | |
| silentStop:Boolean | ||||
| ) | [private] |
Internal handler called by items on completion.
| 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.
| postDelay | true is sent when a delay has completed. |
| function com.mosesSupposes.fuse.Fuse.evtSetStart | ( | o:Object | ) | [private] |
| function com.mosesSupposes.fuse.Fuse.startItem | ( | targs:Array | , | |
| scope:Object | ||||
| ) |
| 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();
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"
| 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.
| fuseOrID:Fuse | (Optional) an existing Fuse or Fuse's id or label in which to open the new group. |
| 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();
| 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
| 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();
| setStart | A setStartProps call is generated from all arguments before the Fuse begins playing. |
| static function com.mosesSupposes.fuse.Fuse.startRecent | ( | setStart:Object | ) | [static] |
| static function com.mosesSupposes.fuse.Fuse.addCommand | ( | commandOrScope:Object | , | |
| indexOrFunc:Object | , | |||
| argument:Object | ||||
| ) | [static] |
Simple Syntax: Multi-purpose metho