Packagecom.gskinner.motion
Classpublic class GTweenTimeline
InheritanceGTweenTimeline Inheritance GTween Inheritance flash.events.EventDispatcher

GTweenTimeline ©2008 Grant Skinner, gskinner.com. Visit www.gskinner.com/libraries/gtween/ for documentation, updates and more free code. Licensed under the MIT license - see the source file header for more information.
GTweenTimeline is a powerful sequencing engine for GTween. It allows you to build a virtual timeline with tweens, actions (callbacks), and labels. It supports all of the features of GTween, so you can repeat, reverse, and pause the timeline. You can even embed timelines within each other. GTweenTimeline adds about 1kb above GTween.



Public Properties
 PropertyDefined by
 InheritedactiveTicker : ITicker
[static] The currently active Ticker object.
GTween
 InheritedautoPlay : Boolean = true
Indicates whether the tween should automatically play when an end value is changed.
GTween
 InheritedautoRotation : Boolean = false
When true, the tween will always rotate in the shortest direction to reach an end rotation value.
GTween
 InheritedautoVisible : Boolean = true
Indicates whether the target's visible property should automatically be set to false when its alpha value is tweened to 0 or less.
GTween
  currentLabel : String
[read-only] Returns the label at the current position, or the previous label irrespective of whether the tween is playing forwards or backwards.
GTweenTimeline
 Inheriteddata : *
Allows you to associate arbitrary data with your tween.
GTween
 InheriteddefaultEase : Function
[static] Specifies the default easing function to use with new tweens.
GTween
 Inheriteddelay : Number
The length of the delay in frames or seconds (depending on the timingMode).
GTween
 Inheritedduration : Number = 1
The length of the tween in frames or seconds (depending on the timingMode).
GTween
 Inheritedease : Function
The easing function to use for calculating the tween.
GTween
 InheritedlockStartProperties : Boolean
If set to true, this prevents the tween from reinitializing its start properties automatically (ex.
GTween
 InheritednextTween : GTween
Specifies another GTween instance that will have paused=false called on it when this tween completes.
GTween
 InheritedpauseAll : Boolean = false
[static] Setting this to true pauses all tween instances.
GTween
 Inheritedpaused : Boolean
Indicates whether the tween is currently paused.
GTween
 Inheritedposition : Number
Gets and sets the position in the tween in frames or seconds (depending on the timingMode).
GTween
 InheritedpropertyTarget : Object
Returns the object that will have its property tweened.
GTween
 Inheritedproxy : Object
The proxy object allows you to work with the properties and methods of the target object directly through GTween.
GTween
 Inheritedreflect : Boolean = false
Indicates whether the tween should use the reflect mode when repeating.
GTween
 Inheritedrepeat : int = 0
The number of times this tween will repeat.
GTween
 Inheritedreversed : Boolean
Indicates whether a tween should run in reverse.
GTween
 InheritedrotationProperties : Object
[static] A hash table specifying properties that should be affected by autoRotation.
GTween
 Inheritedsnapping : Boolean = false
If set to true, tweened values specified by snappingProperties will be rounded (snapped) before they are assigned to the target.
GTween
 InheritedsnappingProperties : Object
[static] A hash table specifying properties that should have their value rounded (snapped) before being applied.
GTween
 Inheritedstate : String
Returns the current positional state of the tween.
GTween
 Inheritedtarget : Object
The target object to tween.
GTween
 InheritedtimeInterval : uint
[static] Sets the time in milliseconds between updates when timingMode is set to GTween.TIME ("time").
GTween
 InheritedtimingMode : String
[static] Indicates how GTween should deal with timing.
GTween
 InheritedtweenPosition : Number
Returns the calculated absolute position in the tween.
GTween
Public Methods
 MethodDefined by
  
GTweenTimeline(target:Object = null, duration:Number = 10, properties:Object = null, tweenProperties:Object = null, tweens:Array = null)
Constructs a new GTweenTimeline instance.
GTweenTimeline
  
addCallback(position:Number, callback:Function, parameters:Array = null):void
Adds a callback function at the specified position.
GTweenTimeline
  
addLabel(position:Number, label:String):void
Adds a label at the specified position.
GTweenTimeline
  
addTween(startPosition:Number, tween:GTween):void
Adds a tween to the timeline, which will start playing at the specified start position.
GTweenTimeline
  
addTweens(tweens:Array):void
Shortcut method for adding a number of tweens at once.
GTweenTimeline
 Inherited
beginning():void
Jumps the tween to its beginning.
GTween
  
Calculates the duration of the timeline based on the tweens and callbacks that have been added to it.
GTweenTimeline
 Inherited
deleteProperty(name:String):Boolean
Removes a end value from the tween.
GTween
 Inherited
end():void
Jumps the tween to its end.
GTween
 Inherited
getProperties():Object
Returns the hash table of all end properties and their values.
GTween
 Inherited
getProperty(name:String):Number
Returns the end value for the specified property if one exists.
GTween
 Inherited
Returns the hash table of all start properties and their values.
GTween
  
goto(labelOrPosition:*):void
Jumps the timeline to the specified label or numeric position without affecting its paused state.
GTweenTimeline
  
gotoAndPlay(labelOrPosition:*):void
Jumps the timeline to the specified label or numeric position and plays it.
GTweenTimeline
  
gotoAndStop(labelOrPosition:*):void
Jumps the timeline to the specified label or numeric position and pauses it.
GTweenTimeline
 Inherited
invalidate():void
Invalidate forces the tween to repopulate all of the initial properties from the target object, and start playing if autoplay is set to true.
GTween
 Inherited
linearEase(t:Number, b:Number, c:Number, d:Number):Number
[static] The default easing function used by GTween.
GTween
 Inherited
pause():void
Pauses the tween by stopping tick from being automatically called.
GTween
 Inherited
play():void
Plays a tween by incrementing the position property each frame.
GTween
  
removeCallback(position:Number):void
Removes the callback at the specified position.
GTweenTimeline
  
removeLabel(label:String):void
Removes the specified label.
GTweenTimeline
  
removeTween(tween:GTween):void
Removes the specified tween.
GTweenTimeline
 Inherited
reverse(suppressEvents:Boolean = true):void
Toggles the reversed property and inverts the current tween position.
GTween
 Inherited
setAssignment(assignmentTarget:Object = null, assignmentProperty:String = null):void
Allows you to tween objects that require re-assignment whenever they are modified by reassigning the target object to a specified property of another object.
GTween
  
setPosition(value:Number, suppressEvents:Boolean = true):void
GTweenTimeline
 Inherited
setProperties(properties:Object):void
Shorthand method for making multiple setProperty calls quickly.
GTween
 Inherited
setProperty(name:String, value:Number):void
Sets the numeric end value for a property on the target object that you would like to tween.
GTween
  
setPropertyValue(target:Object, propertyName:String, value:*):void
[static] Sets a property value on a specified target object.
GTweenTimeline
 Inherited
setStartProperties(properties:Object):void
Allows you to manually assign the start property values for a tween.
GTween
 Inherited
setTweenProperties(properties:Object):void
Shortcut method for setting multiple properties on the tween instance quickly.
GTween
Events
 EventSummaryDefined by
 Inherited This event is dispatched each time the tween updates properties on its target.GTween
 Inherited Dispatched when a tween ends (its position equals its duration).GTween
 Inherited Dispatched when a tween copies its initial properties and starts tweening.GTween
Public Constants
 ConstantDefined by
 InheritedDELAY : String = "delay"
[static] Constant for the DELAY state.
GTween
 InheritedEND : String = "end"
[static] Constant for the END state.
GTween
 InheritedFRAME : String = "frame"
[static] Constant for the FRAME timingMode.
GTween
 InheritedHYBRID : String = "hybrid"
[static] Constant for the HYBRID timingMode.
GTween
 InheritedSTART : String = "start"
[static] Constant for the START state.
GTween
 InheritedTIME : String = "time"
[static] Constant for the TIME timingMode.
GTween
 InheritedTWEEN : String = "tween"
[static] Constant for the TWEEN state.
GTween
Property detail
currentLabelproperty
currentLabel:String  [read-only]

Returns the label at the current position, or the previous label irrespective of whether the tween is playing forwards or backwards. For example, if there are labels at 2, 4, and 7, and the current position is 6, the currentLabel will be the label at position 4.

Implementation
    public function get currentLabel():String
Constructor detail
GTweenTimeline()constructor
public function GTweenTimeline(target:Object = null, duration:Number = 10, properties:Object = null, tweenProperties:Object = null, tweens:Array = null)

Constructs a new GTweenTimeline instance.

Parameters
target:Object (default = null) — The object whose properties will be tweened. Defaults to null.
 
duration:Number (default = 10) — The length of the tween in frames or seconds depending on the timingMode. Defaults to 10.
 
properties:Object (default = null) — An object containing destination property values. For example, to tween to x=100, y=100, you could pass {x:100, y:100} as the props object.
 
tweenProperties:Object (default = null) — An object containing properties to set on this tween. For example, you could pass {ease:myEase} to set the ease property of the new instance. This also provides a shortcut for setting up event listeners. See .setTweenProperties() for more information.
 
tweens:Array (default = null) — An array of alternating start positions and tween instances. For example, the following array would add 3 tweens starting at positions 2, 6, and 8: [2, tween1, 6, tween2, 8, tween3]
Method detail
addCallback()method
public function addCallback(position:Number, callback:Function, parameters:Array = null):void

Adds a callback function at the specified position. When the timeline's playhead passes over or lands on the position while playing the callback will be called with the parameters specified. Callbacks will not be called when manually adjusting the position using the position property (see position for more information).

Note that this can be used in conjunction with the static setPropertyValue method to easily set properties on objects in the timeline.

Parameters
position:Number — The position to add the callback at in frames or seconds (as per the timing mode of this tween).
 
callback:Function — The function to call.
 
parameters:Array (default = null) — Optional array of parameters to pass to the callback when it is called.
addLabel()method 
public function addLabel(position:Number, label:String):void

Adds a label at the specified position. You can use gotoAndPlay or gotoAndStop to jump to labels you add, or use currentLabel to check what the last label you passed was.

Parameters
position:Number — The position to add the label at in frames or seconds (as per the timing mode of this tween).
 
label:String — The label to add.
addTween()method 
public function addTween(startPosition:Number, tween:GTween):void

Adds a tween to the timeline, which will start playing at the specified start position. The tween will play synchronized with the timeline, with all of its behaviours intact (ex. reversed, repeat, reflect) except for delay (which is accomplished with the startPosition parameter instead).

Parameters
startPosition:Number — The starting position for this tween in frames or seconds (as per the timing mode of this tween).
 
tween:GTween — The GTween instance to add. Note that this can be any subclass of GTween, including another GTweenTimeline.
addTweens()method 
public function addTweens(tweens:Array):void

Shortcut method for adding a number of tweens at once.

Parameters
tweens:Array — An array of alternating start positions and tween instances. For example, the following array would add 3 tweens starting at positions 2, 6, and 8: [2, tween1, 6, tween2, 8, tween3]
calculateDuration()method 
public function calculateDuration():void

Calculates the duration of the timeline based on the tweens and callbacks that have been added to it.

goto()method 
public function goto(labelOrPosition:*):void

Jumps the timeline to the specified label or numeric position without affecting its paused state.

Parameters
labelOrPosition:* — The label name or numeric position in frames or seconds (as per the timing mode of this tween) to jump to.
gotoAndPlay()method 
public function gotoAndPlay(labelOrPosition:*):void

Jumps the timeline to the specified label or numeric position and plays it.

Parameters
labelOrPosition:* — The label name or numeric position in frames or seconds (as per the timing mode of this tween) to jump to.
gotoAndStop()method 
public function gotoAndStop(labelOrPosition:*):void

Jumps the timeline to the specified label or numeric position and pauses it.

Parameters
labelOrPosition:* — The label name or numeric position in frames or seconds (as per the timing mode of this tween) to jump to.
removeCallback()method 
public function removeCallback(position:Number):void

Removes the callback at the specified position.

Parameters
position:Number — The position of the callback to remove in frames or seconds (as per the timing mode of this tween).
removeLabel()method 
public function removeLabel(label:String):void

Removes the specified label.

Parameters
label:String — The label to remove.
removeTween()method 
public function removeTween(tween:GTween):void

Removes the specified tween. Note that this will remove all instances of the tween if has been added multiple times to the timeline.

Parameters
tween:GTween — The GTween instance to remove.
setPosition()method 
public override function setPosition(value:Number, suppressEvents:Boolean = true):voidParameters
value:Number
 
suppressEvents:Boolean (default = true)
setPropertyValue()method 
public static function setPropertyValue(target:Object, propertyName:String, value:*):void

Sets a property value on a specified target object. This is provided to make it easy to set properties in a GTweenTimeline using addCallback. For example, to set the visible property to true on a movieclip "foo" at 3 seconds into the timeline, you could use the following code:
myTimeline.addCallback(3,GTweenTimeline.setPropertyValue,[foo,"visible",true]);

Parameters
target:Object — The object to set the property value on.
 
propertyName:String — The name of the property to set.
 
value:* — The value to assign to the property.