TweenJS  0.3.0

TweenJS > TweenJS > Tween

Class Tween

Returns a new Tween instance. See Tween.get for param documentation.


Tween ( )


_actions - protected Array

_curQueueProps - protected Object

_initQueueProps - protected Object

_listeners - protected static Array[Tween]

_paused - protected Boolean

_plugins - protected static Object

_prevPos - protected Number

Normalized position.

_prevPosition - protected Number

Raw position.

_stepPosition - protected Number

The position within the current step.

_steps - protected Array

_target - protected Object

_useTicks - protected Boolean

duration - Number

Read-only. Specifies the total duration of this tween in milliseconds (or ticks if useTicks is true). This value is automatically updated as you modify the tween. Changing it directly could result in unexpected behaviour.

IGNORE - static Object

Constant returned by plugins to tell the tween not to use default assignment.

ignoreGlobalPause - Boolean

Causes this tween to continue playing when a global pause is active. For example, if TweenJS is using Ticker, then setting this to true (the default) will cause this tween to be paused when Ticker.setPaused(true) is called. See Tween.tick() for more info. Can be set via the props param.

loop - Boolean

If true, the tween will loop when it reaches the end. Can be set via the props param.

LOOP - static Number

Constant defining the loop actionsMode for use with setPosition.

NONE - static Number

Constant defining the none actionsMode for use with setPosition.

onChange - Function

Called whenever the tween's position changes with a single parameter referencing this tween instance.

pluginData - Object

Allows you to specify data that will be used by installed plugins. Each plugin uses this differently, but in general you specify data by setting it to a property of pluginData with the same name as the plugin class.
Ex. myTween.pluginData.PluginClassName = data;

Also, most plugins support a property to enable or disable them. This is typically the plugin class name followed by "_enabled".
Ex. myTween.pluginData.PluginClassName_enabled = false;

Some plugins also store instance data in this object, usually in a property named _PluginClassName. See the documentation for individual plugins for more details.

position - Object

Read-only. The current normalized position of the tween. This will always be a value between 0 and duration. Changing this property directly will have no effect.

REVERSE - static Number

Constant defining the reverse actionsMode for use with setPosition.

target - Object

Read-only. The target of this tween. This is the object on which the tweened properties will be changed. Changing this property after the tween is created will not have any effect.



protected void _addAction ( )
Returns: void


protected void _addStep ( )
Returns: void


protected void _appendQueueProps ( )
Returns: void


protected void _cloneProps ( )
Returns: void


protected static void _register ( )
Registers or unregisters a tween with the ticking system.
Returns: void


protected void _runActions ( )
Returns: void


protected void _set ( )
Returns: void


protected void _updateTargetProps ( )
Returns: void


call ( callback , params , scope )
Queues an action to call the specified function. For example: myTween.wait(1000).call(myFunction); would call myFunction() after 1s.
callback <object> The function to call.
params <object> Optional. The parameters to call the function with. If this is omitted, then the function will be called with a single param pointing to this tween.
scope <object> Optional. The scope to call the function in. If omitted, it will be called in the target's scope.


protected void clone ( )
Returns: void


static void get ( target , props )
Returns a new tween instance. This is functionally identical to using "new Tween(...)", but looks cleaner with the chained syntax of TweenJS.
target <object> The target object that will have its properties tweened.
props <loop:true, paused:true> The configuration properties to apply to this tween instance (ex. ). All properties default to false. Supported props are:
  • loop: sets the loop property on this tween.
  • useTicks: uses ticks for all durations instead of milliseconds.
  • ignoreGlobalPause: sets the ignoreGlobalPause property on this tween.
  • override: if true, Tween.removeTweens(target) will be called to remove any other tweens with the same target.
  • paused: indicates whether to start the tween paused.
  • position: indicates the initial position for this tween.
  • onChanged: specifies an onChange handler for this tween.
Returns: void


static hasActiveTweens ( target )
Indicates whether there are any active tweens on the target object (if specified) or in general.
target <object> Optional. If not specified, the return value will indicate if there are any active tweens on any target.


protected void initialize ( )
Returns: void


static void installPlugin ( plugin , properties )
Installs a plugin, which can modify how certain properties are handled when tweened. See the CSSPlugin for an example of how to write TweenJS plugins.
plugin <object>
properties <object>
Returns: void


void pause ( tween )
Queues an action to to pause the specified tween.
tween <object> The tween to play. If null, it pauses this tween.
Returns: void


play ( tween )
Queues an action to to play (unpause) the specified tween. This enables you to sequence multiple tweens. Ex.{x:100},500).play(otherTween);
tween <object> The tween to play.


static void removeTweens ( target )
Removes all existing tweens for a target. This is called automatically by new tweens if the "override" prop is true.
target <object> The target object to remove existing tweens from.
Returns: void


set ( props , target )
Queues an action to set the specified props on the specified target. If target is null, it will use this tween's target. Ex. myTween.wait(1000).set({visible:false},foo);
props <visible:false> The properties to set (ex. ).
target <object> Optional. The target to set the properties on. If omitted, they will be set on the tween's target.


void setPaused ( value )
Pauses or plays this tween.
value <object> Indicates whether the tween should be paused (true) or played (false).
Returns: void


setPosition ( value , actionsMode )
Advances the tween to a specified position.
value <object> The position to seek to in milliseconds (or ticks if useTicks is true).
actionsMode <object> Optional parameter specifying how actions are handled (ie. call, set, play, pause): Tween.NONE (0) - run no actions. Tween.LOOP (1) - if new position is less than old, then run all actions between old and duration, then all actions between 0 and new. Defaults to LOOP. Tween.REVERSE (2) - if new position is less than old, run all actions between them in reverse.


static void tick ( delta , paused )
Advances all tweens. This typically uses the Ticker class (available in the EaselJS library), but you can call it manually if you prefer to use your own "heartbeat" implementation.
delta <object> The change in time in milliseconds since the last tick. Required unless all tweens have useTicks set to true.
paused <object> Indicates whether a global pause is in effect. Tweens with ignoreGlobalPause will ignore this, but all others will pause if this is true.
Returns: void


to ( props , duration , ease )
Queues a tween from the current values to the target properties. Set duration to 0 to jump to these value. Numeric properties will be tweened from their current value in the tween to the target value. Non-numeric properties will be set at the end of the specified duration.
props <x:300> An object specifying property target values for this tween (Ex. would tween the x property of the target to 300).
duration <object> Optional. The duration of the wait in milliseconds (or in ticks if useTicks is true). Defaults to 0.
ease <object> Optional. The easing function to use for this tween. Defaults to a linear ease.


String toString ( )
Returns a string representation of this object.
Returns: String
a string representation of the instance.


wait ( duration )
Queues a wait (essentially an empty tween).
duration <object> The duration of the wait in milliseconds (or in ticks if useTicks is true).