TweenJS

TweenJS  0.2.0

TweenJS > TweenJS > Tween
Search:
 
Filters

Class Tween

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

Constructor

Tween ( )

Properties

_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 property specifying the total duration of this tween in milliseconds (or ticks if useTicks is true). This value is automatically updated as you modify the tween.

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 - static Number

Constant defining the loop actionsMode for use with setPosition.

loop - Boolean

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

NONE - static Number

Constant defining the none actionsMode for use with setPosition.

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.

REVERSE - static Number

Constant defining the reverse actionsMode for use with setPosition.

Methods

_addAction

protected void _addAction ( )
Returns: void

_addStep

protected void _addStep ( )
Returns: void

_appendQueueProps

protected void _appendQueueProps ( )
Returns: void

_cloneProps

protected void _cloneProps ( )
Returns: void

_register

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

_runActions

protected void _runActions ( )
Returns: void

_set

protected void _set ( )
Returns: void

_updateTargetProps

protected void _updateTargetProps ( )
Returns: void

call

call ( callback , params , scope )
Queues an action to call the specified function. For example: myTween.wait(1000).call(myFunction); would call myFunction() after 1s.
Parameters:
callback <object> The function to call.
params <object> 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> The scope to call the function in. If omitted, it will be called in the target's scope.

clone

protected void clone ( )
Returns: void

get

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.
Parameters:
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 timeline
Returns: void

initialize

protected void initialize ( )
Returns: void

installPlugin

static void installPlugin ( plugin , properties )
TODO: doc.
Parameters:
plugin <object>
properties <object>
Returns: void

pause

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

play

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

removeTweens

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

set

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);
Parameters:
props <visible:false> The properties to set (ex. ).
target <object> The target to set the properties on. If omitted, they will be set on the tween's target.

setPaused

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

setPosition

setPosition ( value , actionsMode )
Advances the tween to a specified position.
Parameters:
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.

tick

static void tick ( delta , paused )
Advances all tweens. This typically uses the Ticker class (when available), but you can call it manually if you prefer to use your own "heartbeat" implementation.
Parameters:
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

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.
Parameters:
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> The duration of the wait in milliseconds (or in ticks if useTicks is true).
ease <object> The easing function to use for this tween.

toString

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

wait

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