Package | com.gskinner.motion |
Class | public class GTween |
Inheritance | GTween ![]() |
mySpriteTween.proxy.rotation += 50;
Property | Defined by | ||
---|---|---|---|
assignmentProperty : String
Allows you to reassign the .target object back to a property specified by assignmentProperty of an object specified by assignmentTarget.
| GTween | ||
assignmentTarget : Object
Allows you to reassign the .target object back to a property specified by assignmentProperty of an object specified by assignmentTarget.
| GTween | ||
autoHide : Boolean
Indicates whether the target's visible property should automatically be set to false when its alpha value is tweened to 0 or less.
| GTween | ||
autoPlay : Boolean = true
Indicates whether the tween should automatically play when a destination value is changed.
| GTween | ||
autoReverse : Boolean = false
Specifies whether the tween should automatically reverse its initial and destination property values when it reaches its end.
| GTween | ||
data : *
Allows you to associate arbitrary data with your tween.
| GTween | ||
delay : Number
The length of the delay in frames or seconds (depending on the timingMode).
| GTween | ||
duration : Number
The length of the tween in frames or seconds (depending on the timingMode).
| GTween | ||
ease : Function
The transition function to use for calculating the tween.
| GTween | ||
lastProgressPoint : * [read-only]
Returns the name of the last progress point that was passed, or null if none.
| GTween | ||
nextTween : GTween
Specifies another GTween instance that will have .play() called on it when this tween completes.
| GTween | ||
pauseAll : Boolean = false [static] Setting this to true pauses all tween instances.
| GTween | ||
paused : Boolean
Indicates whether the tween is currently paused (including when it is at the beginning or end).
| GTween | ||
position : Number
Gets and sets the position in the tween in frames or seconds (depending on the timingMode).
| GTween | ||
proxy : Object [read-only]
The proxy object allows you to work with the properties and methods of the target object directly through GTween.
| GTween | ||
roundValues : Boolean = false
If set to true, all tweened values will be rounded before they are assigned to the target.
| GTween | ||
state : String [read-only]
Returns the current positional state of the tween.
| GTween | ||
target : Object
The target object to tween.
| GTween | ||
timeInterval : uint [static]
Sets the time in milliseconds between updates when timingMode is set to GTween.TIME ("time").
| GTween | ||
timingMode : String [static]
Indicates how GTween should deal with timing.
| GTween | ||
useSmartRotation : Boolean = true
When true, the tween will always rotate in the shortest direction to reach the destination rotation.
| GTween |
Method | Defined by | ||
---|---|---|---|
GTween(target:Object = null, duration:Number = 10, properties:Object = null, tweenProperties:Object = null)
Constructs a new GTween instance.
| GTween | ||
Adds a child tween.
| GTween | ||
addProgressPoint(position:Number, data:*):void
Adds a tween position at which to generate a progress event.
| GTween | ||
beginning():void
Jumps the tween to its beginning and pauses it.
| GTween | ||
Creates a clone of the GTween instance.
| GTween | ||
deleteProperty(propertyName:String):Boolean
Removes a destination value from the tween.
| GTween | ||
end(endNextTween:Boolean = true):void
Jumps the tween to its end.
| GTween | ||
getProperty(propertyName:String):Number
Returns the destination value for the specified property if one exists.
| GTween | ||
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 | ||
pause():void
Pauses the tween by stopping tick from being automatically called.
| GTween | ||
play():void
Plays a tween by incrementing the position property each frame.
| GTween | ||
removeChild(child:GTween):void
Removes a child tween.
| GTween | ||
removeProgressPoint(position:Number):void
Removes the progress point at the specified position.
| GTween | ||
reset():void
Resets the tween, pausing it, deleting all destination values, resetting the tween position to the beginning, and nulling the lastProgressPoint.
| GTween | ||
reverse(reverseChildren:Boolean = true):void
Reverses the tween by swapping its initial and destination properties.
| GTween | ||
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 | ||
setProperties(properties:Object):void
Shorthand method for making multiple setProperty calls quickly.
| GTween | ||
setProperty(propertyName:String, value:Number):void
Sets the numeric destination value for a property on the target object that you would like to tween.
| GTween | ||
setTweenProperties(tweenProperties:Object):void
Shortcut method for setting multiple properties on the tween object quickly.
| GTween |
Constant | Defined by | ||
---|---|---|---|
BEGINNING : String = "beginning" [static] Constant for the BEGINNING state.
| GTween | ||
DELAY_PHASE : String = "delayPhase" [static] Constant for the DELAY_PHASE state.
| GTween | ||
END : String = "end" [static] Constant for the END state.
| GTween | ||
FRAME : String = "frame" [static] Constant for the FRAME timingMode.
| GTween | ||
HYBRID : String = "hybrid" [static] Constant for the HYBRID timingMode.
| GTween | ||
PROGRESS : String = "progress" [static] Constant for the PROGRESS event type.
| GTween | ||
TIME : String = "time" [static]
Dispatched when a tween activates and first starts running.
| GTween | ||
TWEEN_PHASE : String = "tweenPhase" [static] Constant for the TWEEN_PHASE state.
| GTween |
assignmentProperty | property |
public var assignmentProperty:String
Allows you to reassign the .target object back to a property specified by assignmentProperty of an object specified by assignmentTarget.
Useful for tweening elements like colorTransform that need to be reassigned to have an effect.
See setAssignment() for more information.
See also
assignmentTarget | property |
public var assignmentTarget:Object
Allows you to reassign the .target object back to a property specified by assignmentProperty of an object specified by assignmentTarget.
Useful for tweening elements like colorTransform that need to be reassigned to have an effect.
See setAssignment() for more information.
See also
autoHide | property |
autoHide:Boolean
[read-write]Indicates whether the target's visible property should automatically be set to false when its alpha value is tweened to 0 or less. Only affects objects with a visible property.
Implementation public function get autoHide():Boolean
public function set autoHide(value:Boolean):void
autoPlay | property |
public var autoPlay:Boolean = true
Indicates whether the tween should automatically play when a destination value is changed.
autoReverse | property |
public var autoReverse:Boolean = false
Specifies whether the tween should automatically reverse its initial and destination property values when it reaches its end.
Example: this could be used to create a tween that automatically plays forward and in reverse continually with:
myTween.autoReverse = true;
myTween.nextTween = myTween; // automatically play this tween again when it ends
data | property |
public var data:*
Allows you to associate arbitrary data with your tween. For example, you might use this to reference specific data when handling events from tweens.
delay | property |
delay:Number
[read-write]The length of the delay in frames or seconds (depending on the timingMode). The delay occurs before a tween reads initial values or starts playing.
Implementation public function get delay():Number
public function set delay(value:Number):void
duration | property |
duration:Number
[read-write]The length of the tween in frames or seconds (depending on the timingMode). Setting this will also update any child transitions that have synchDuration set to true.
Implementation public function get duration():Number
public function set duration(value:Number):void
ease | property |
public var ease:Function
The transition function to use for calculating the tween. This can be any standard tween function, such as the tween functions in fl.motion.easing.that come with Flash CS3.
lastProgressPoint | property |
lastProgressPoint:*
[read-only]Returns the name of the last progress point that was passed, or null if none.
Implementation public function get lastProgressPoint():*
nextTween | property |
public var nextTween:GTween
Specifies another GTween instance that will have .play() called on it when this tween completes.
pauseAll | property |
public static var pauseAll:Boolean = false
Setting this to true pauses all tween instances. This does not affect individual tweens' .paused property.
paused | property |
paused:Boolean
[read-write]Indicates whether the tween is currently paused (including when it is at the beginning or end). See play() and pause() for more information.
Implementation public function get paused():Boolean
public function set paused(value:Boolean):void
position | property |
position:Number
[read-write]
Gets and sets the position in the tween in frames or seconds (depending on the timingMode). The value will be between -delay and duration (beginning and end of tween respectively).
Note: Normally this value would be set and modified automatically by the tween, but is provided for advanced users.
public function get position():Number
public function set position(value:Number):void
proxy | property |
proxy:Object
[read-only]
The proxy object allows you to work with the properties and methods of the target object directly through GTween.
Numeric property assignments will be used by GTween as destination values. The proxy will return GTween destination values
when they are set, or the target's property values if they are not. Delete operations on properties will result in a deleteProperty
call. All other property access and method execution through proxy will be passed directly to the target object.
Example 1: Equivalent to calling myGTween.setProperty("scaleY",2.5):
myGTween.proxy.scaleY = 2.5;
Example 2: Gets the current rotation value from the target object (because it hasn't been set yet on the GTween), adds 100 to it, and then
calls setProperty on the GTween instance with the appropriate value:
myGTween.proxy.rotation += 100;
Example 3: Sets a destination value (through setProperty) for scaleX, then retrieves it from GTween (because it will always return
destination values when available):
trace(myGTween.proxy.scaleX); // 1 (value from target, because no destination value is set)
myGTween.proxy.scaleX = 2; // set a destination value
trace(myGTween.proxy.scaleX); // 2 (destination value from GTween)
trace(myGTween.target.scaleX); // 1 (current value from target)
Example 4: Property deletions only affect destination properties on GTween, not the target object:
myGTween.proxy.rotation = 50; // set a destination value
trace(myGTween.proxy.rotation); // 50 (destination value from GTween)
delete(myGTween.proxy.rotation); // delete the destination value
trace(myGTween.proxy.rotation); // 0 (current value from target)
Example 5: Non-numeric property access is passed through to the target:
myGTween.proxy.blendMode = "multiply"; // passes value assignment through to the target
trace(myGTween.target.blendMode); // "multiply" (value from target)
trace(myGTween.proxy.blendMode); // "multiply" (value passed through from target)
Example 6: Method calls are passed through to target:
myGTween.proxy.gotoAndStop(30); // gotoAndStop(30) will be called on the target
public function get proxy():Object
roundValues | property |
public var roundValues:Boolean = false
If set to true, all tweened values will be rounded before they are assigned to the target.
state | property |
state:String
[read-only]
Returns the current positional state of the tween. This does not indicate if the tween is paused - use the .paused property for this. Possible values are:
GTween.BEGINNING, GTween.DELAY_PHASE, GTween.TWEEN_PHASE, GTween.END
The beginning state indicates the tween either has not been played. The tween's position will equal -delay.
The delayPhase state indicates that the tween is active (running), but is currently delaying prior to initing. The tween's position is less than 0. Note that it may be paused.
The tweenPhase state indicates that the tween has inited, and is tweening the property values. Note that it may be paused.
The end state indicates that the tween has completed playing. Setting any new properties on the tween will reset it, and set its state to beginning.
New tweens with autoplay set to false start with a state of BEGINNING. When first played, a tween will have a state of either DELAY_PHASE (if delay > 0) or TWEEN_PHASE (if delay == 0).
When the delay ends, and tweening begins, the state will change to TWEEN_PHASE. When the tween reaches its end (position == duration), the state will be set to END. If you change any destination
properties on an ended tween, its state will be set back to BEGINNING.
public function get state():String
target | property |
target:Object
[read-write]The target object to tween. This can be any kind of object.
Implementation public function get target():Object
public function set target(value:Object):void
timeInterval | property |
timeInterval:uint
[read-write]Sets the time in milliseconds between updates when timingMode is set to GTween.TIME ("time"). Setting this to a lower number will generally result in smoother animations but higher CPU usage. Defaults to 40ms (~25 updates per second).
Implementation public static function get timeInterval():uint
public function set timeInterval(value:uint):void
timingMode | property |
timingMode:String
[read-write]
Indicates how GTween should deal with timing. This can be set to either GTween.TIME, GTween.FRAME, or GTween.HYBRID.
In frame mode, GTween will update once every frame, and all positional values are specified in frames (duration, position, delay, and progress point positions).
In time mode, updates will occur at an interval specified by the timeInterval property, independent of the frame rate, and all positional values are
specified in seconds.
In hybrid mode, all updates occur on a frame, but all positional values are specified in seconds. Each frame the tween will calculate it's position based on the elapsed time.
This offers lower CPU usage, and a more familiar time based interface, but can result in choppy animations in high CPU situations.
The time mode will generally run more smoothly, as it is less dependent on the running frame rate of the movie. The frame mode will generally use less CPU,
and can be synched with timeline animations. You can change modes at any time, but existing tweens will continue to use the mode that was active when they were created.
public static function get timingMode():String
public function set timingMode(value:String):void
useSmartRotation | property |
public var useSmartRotation:Boolean = true
When true, the tween will always rotate in the shortest direction to reach the destination rotation. For example, rotating from 355 degress to 5 degrees will rotate 10 degrees clockwise with useSmartRotation set to true. It would rotate 350 degrees counter-clockwise with useSmartRotation set to false.
GTween | () | constructor |
public function GTween(target:Object = null, duration:Number = 10, properties:Object = null, tweenProperties:Object = null)
Constructs a new GTween instance.
Parameterstarget: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 {autoHide:true} to set the autoHide property of the new instance. This also provides a shortcut for setting up event listeners. See .setTweenProperties() for more information.
|
addChild | () | method |
public function addChild(child:GTween, synchDuration:Boolean = true):void
Adds a child tween. Child tweens are played in synch with their parent (ie. their position properties are synchronized). By specifying true for synchDuration, you can also ensure that a child will keep its duration synchronized with its parent.
Parameterschild:GTween — A GTween instance to add as a child tween.
|
|
synchDuration:Boolean (default = true ) — indicates whether the child tween's duration property should be kept in synch with the parent. Defaults to true. You may choose to set this to false if you have a shorter tween as a child, and want it to end sooner than its parent.
|
addProgressPoint | () | method |
public function addProgressPoint(position:Number, data:*):void
Adds a tween position at which to generate a progress event. You can use this to trigger other functionality at specific points in the tween.
The name is the string value that lastProgressPoint will be set to when the event is dispatched.
Example: This will generate a progress event and set the lastProgressPoint to "middle" half way through a 5 second tween:
myGTween.addProgressPoint(2.5, "middle");
position:Number — The position at which to dispatch a progress event.
|
|
data:* — The name that will be set to lastProgressPoint when this progress point is reached.
|
beginning | () | method |
public function beginning():void
Jumps the tween to its beginning and pauses it. This sets all target properties to their init values, and sets the state to BEGINNING.
clone | () | method |
public function clone(target:Object = null, preserveChildren:Boolean = false, preserveState:Boolean = false):GTween
Creates a clone of the GTween instance. You can optionally specify a different target for the tween, and indicate whether to preserve the state (position and paused properties) of the tween.
Parameterstarget:Object (default = null ) — The target property for the new tween. If null, it will use the target of the tween that is being cloned.
|
|
preserveChildren:Boolean (default = false ) — Indicates whether to copy this instance's children to the new instance. Defaults to false.
|
|
preserveState:Boolean (default = false ) — Indicates whether the position and paused properties should be cloned, or if the new tween should start at position 0, with paused dependent on autoPlay. Defaults to false.
|
GTween |
deleteProperty | () | method |
public function deleteProperty(propertyName:String):Boolean
Removes a destination value from the tween. This prevents the GTween instance from tweening the property.
ParameterspropertyName:String — The name of the destination property to delete.
|
Boolean |
end | () | method |
public function end(endNextTween:Boolean = true):void
Jumps the tween to its end. This is the same as setting position=duration, except it also provides you with the option to also end the nextTween (recursively). This sets all target properties to their destination values, sets the state to END, and fires the COMPLETE event.
ParametersendNextTween:Boolean (default = true )
|
getProperty | () | method |
public function getProperty(propertyName:String):Number
Returns the destination value for the specified property if one exists.
ParameterspropertyName:String — The name of the property to return a destination value for.
|
Number |
invalidate | () | method |
public function 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. If the tween is currently playing, then it will also set the position to 0. For example, if you changed the x and y position of an object while it was playing, you could call invalidate on it to force it to resume the tween with the new property values.
pause | () | method |
public function pause():void
Pauses the tween by stopping tick from being automatically called. This also releases the tween for garbage collection if it is not referenced externally.
play | () | method |
public function play():void
Plays a tween by incrementing the position property each frame. This also prevents the tween from being garbage collected while it is active. This is achieved by way of two methods: 1. If the target object is an IEventDispatcher, then the tween will subscribe to a dummy event using a hard reference. This allows the tween to be garbage collected if its target is also collected, and there are no other external references to it. 2. If the target object is not an IEventDispatcher, then the tween is placed in the activeTweens list, to prevent collection until it is paused or reaches the end of the transition). Note that pausing all tweens via the GTween.pauseAll static property will not free the tweens for collection.
removeChild | () | method |
public function removeChild(child:GTween):void
Removes a child tween.
Parameterschild:GTween — The child GTween instance to remove.
|
removeProgressPoint | () | method |
public function removeProgressPoint(position:Number):void
Removes the progress point at the specified position.
Parametersposition:Number — The position of the progress point to remove.
|
reset | () | method |
public function reset():void
Resets the tween, pausing it, deleting all destination values, resetting the tween position to the beginning, and nulling the lastProgressPoint. This will not change the target's current properties.
reverse | () | method |
public function reverse(reverseChildren:Boolean = true):void
Reverses the tween by swapping its initial and destination properties. If the tween is playing (state = TWEEN_PHASE), it will also
reverse the tween position.
Note: calling reverse on a playing tween may result in unusual results with nonlinear tween functions.
reverseChildren:Boolean (default = true ) — Indicates whether to call reverse on all child tweens.
|
setAssignment | () | method |
public function 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. For example, in order for changes to a colorTransform object to be visible,
it must be assigned back to the .transform.colorTransform property of a display object. To make this work, you would call
myTween.setAssignment(myDisplayObject.transform,"colorTransform");
This will also cause GTween to retrieve the target each time it copies its initial values.
Note: this does not work with filters yet, as they must be assigned to an array first, and then to the filters property. Use GTweenFilter instead.
assignmentTarget:Object (default = null ) — The object to reassign the property on.
|
|
assignmentProperty:String (default = null ) — The name of the property to reassign the target to.
|
setProperties | () | method |
public function setProperties(properties:Object):void
Shorthand method for making multiple setProperty calls quickly.
Example: set x and y destination values:
myGTween.setProperties({x:200, y:400});
properties:Object — An object containing destination property values.
|
setProperty | () | method |
public function setProperty(propertyName:String, value:Number):void
Sets the numeric destination value for a property on the target object that you would like to tween. For example, if you wanted to tween to a new x position, you could use: myGTween.setProperty("x",400). Nonnumeric values are ignored.
ParameterspropertyName:String — The name of the property to tween.
|
|
value:Number — The numeric destination value (the value to tween to).
|
setTweenProperties | () | method |
public function setTweenProperties(tweenProperties:Object):void
Shortcut method for setting multiple properties on the tween object quickly. This does not set destination values (ie. the value to tween to).
This method also provides you with a quick method for adding listeners to specific events, using the special properties:
activateListener, initListener, completeListener, progressListener, changeListener.
Example: This will set the duration, autoReverse, and nextTween properties of a tween, and add a listener for the complete event:
myTween.setTweenProperties({duration:4, autoReverse:true, nextTween:anotherTween, completeListener:completeHandlerFunction});
tweenProperties:Object |
BEGINNING | constant |
public static const BEGINNING:String = "beginning"
Constant for the BEGINNING state.
DELAY_PHASE | constant |
public static const DELAY_PHASE:String = "delayPhase"
Constant for the DELAY_PHASE state.
END | constant |
public static const END:String = "end"
Constant for the END state.
FRAME | constant |
public static const FRAME:String = "frame"
Constant for the FRAME timingMode.
HYBRID | constant |
public static const HYBRID:String = "hybrid"
Constant for the HYBRID timingMode.
PROGRESS | constant |
public static const PROGRESS:String = "progress"
Constant for the PROGRESS event type.
TIME | constant |
public static const TIME:String = "time"
Dispatched when a tween activates and first starts running. That is, when the tween exits the beginning or end state, and enters either the delayPhase or tweenPhase state.
TWEEN_PHASE | constant |
public static const TWEEN_PHASE:String = "tweenPhase"
Constant for the TWEEN_PHASE state.