Package | com.gskinner.motion |
Class | public class GTweeny |
Inheritance | GTweeny ![]() |
Property | Defined by | ||
---|---|---|---|
autoPlay : Boolean = true
Indicates whether the tween should automatically play when an end value is changed.
| GTweeny | ||
autoRotation : Boolean = false
When true, the tween will always rotate in the shortest direction to reach the destination rotation.
| GTweeny | ||
autoVisible : 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.
| GTweeny | ||
data : *
Allows you to associate arbitrary data with your tween.
| GTweeny | ||
defaultEase : Function [static] Specifies the default easing function to use with new tweens.
| GTweeny | ||
delay : Number
The length of the delay in frames or seconds (depending on the timingMode).
| GTweeny | ||
duration : Number = 1
The length of the tween in frames or seconds (depending on the timingMode).
| GTweeny | ||
ease : Function
The easing function to use for calculating the tween.
| GTweeny | ||
nextTween : GTweeny
Specifies another GTween instance that will have paused=false called on it when this tween completes.
| GTweeny | ||
pauseAll : Boolean = false [static] Setting this to true pauses all tween instances.
| GTweeny | ||
paused : Boolean
Indicates whether the tween is currently paused.
| GTweeny | ||
position : Number
Gets and sets the position in the tween in frames or seconds (depending on the timingMode).
| GTweeny | ||
reflect : Boolean = false
Indicates whether the tween should use the reflect mode when repeating.
| GTweeny | ||
repeat : int = 0
The number of times this tween will repeat.
| GTweeny | ||
reversed : Boolean
Indicates whether a tween should run in reverse.
| GTweeny | ||
rotationProperties : Object [static] A hash table specifying properties that should be affected by autoRotation.
| GTweeny | ||
snapping : Boolean = false
If set to true, tweened values specified by snappingProperties will be rounded (snapped) before they are assigned to the target.
| GTweeny | ||
snappingProperties : Object [static] A hash table specifying properties that should have their value rounded (snapped) before being applied.
| GTweeny | ||
target : Object
The target object to tween.
| GTweeny | ||
ticker : HybridTicker [static][read-only] The currently active Ticker object.
| GTweeny | ||
tweenPosition : Number [read-only]
Returns the calculated absolute position in the tween.
| GTweeny |
Method | Defined by | ||
---|---|---|---|
GTweeny(target:Object = null, duration:Number = 10, properties:Object = null, tweenProperties:Object = null)
Constructs a new GTween instance.
| GTweeny | ||
beginning():void
Jumps the tween to its beginning.
| GTweeny | ||
deleteProperty(name:String):Boolean
Removes a end value from the tween.
| GTweeny | ||
end():void
Jumps the tween to its end.
| GTweeny | ||
getProperty(name:String):Number
Returns the destination value for the specified property if one exists.
| GTweeny | ||
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.
| GTweeny | ||
linearEase(t:Number, b:Number, c:Number, d:Number):Number
[static] The default easing function used by GTween.
| GTweeny | ||
pause():void
Pauses the tween by stopping tick from being automatically called.
| GTweeny | ||
play():void
Plays a tween by incrementing the position property each frame.
| GTweeny | ||
reverse(suppressEvents:Boolean = true):void
Toggles the reversed property and inverts the current tween position.
| GTweeny | ||
setPosition(position:Number, suppressEvents:Boolean = true):void
Sets the position of the tween.
| GTweeny | ||
setProperties(properties:Object):void
Shorthand method for making multiple setProperty calls quickly.
| GTweeny | ||
setProperty(name:String, value:Number):void
Sets the numeric end value for a property on the target object that you would like to tween.
| GTweeny | ||
setTweenProperties(properties:Object):void
Shortcut method for setting multiple properties on the tween instance quickly.
| GTweeny |
Event | Summary | Defined by | ||
---|---|---|---|---|
This event is dispatched each time the tween updates properties on its target. | GTweeny | |||
Dispatched when a tween ends (its position equals its duration). | GTweeny | |||
Dispatched when a tween copies its initial properties and starts tweening. | GTweeny |
autoPlay | property |
public var autoPlay:Boolean = true
Indicates whether the tween should automatically play when an end value is changed.
autoRotation | property |
public var autoRotation:Boolean = false
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 .autoRotation set to true. It would rotate 350 degrees counter-clockwise with .autoRotation set to false. This affects all properties specified in the static .rotationProperties hash table.
autoVisible | property |
public var autoVisible: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. Only affects objects with a visible property.
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.
defaultEase | property |
public static var defaultEase:Function
Specifies the default easing function to use with new tweens. If null, GTween.linearEase will be used.
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 |
public var duration:Number = 1
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.
ease | property |
public var ease:Function
The easing 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. New tweens will have this set to the defaultTween. Setting this to null will cause GTween to throw null reference errors.
nextTween | property |
public var nextTween:GTweeny
Specifies another GTween instance that will have paused=false 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. 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). This value can be any number, and will be resolved to a tweenPosition value
prior to being applied to the tweened values. See tweenPosition for more information.
Negative values
Values below 0 will always resolve to a tweenPosition of 0. Negative values can be used to set up a delay on the tween, as the tween will have to count up to 0 before initing.
Positive values
Positive values are resolved based on the duration, repeat, reflect, and reversed properties.
public function get position():Number
public function set position(value:Number):void
reflect | property |
public var reflect:Boolean = false
Indicates whether the tween should use the reflect mode when repeating. If reflect is set to true, then the tween will play backwards on every other repeat. This has similar effects to reversed, but the properties are exclusive of one another. For instance, with reversed set to false, reflected set to true, and a repeat of 1, the tween will play from start to end, then repeat and reflect to play from end to start. If in the previous example reversed was instead set to true, the tween would play from end to start, then repeat and reflect to play from start to end. Finally, with reversed set to false, reflected set to false, and a repeat of 1, the tween will play from start to end, then repeat from start to end
repeat | property |
public var repeat:int = 0
The number of times this tween will repeat. If 0, the tween will only run once. If 1 or more, the tween will repeat that many times. If -1, the tween will repeat forever.
reversed | property |
reversed:Boolean
[read-write]Indicates whether a tween should run in reverse. In the simplest examples this means that the tween will play from its end values to its start values. See "reflect" for more information on how these two related properties interact. Also see reverse().
Implementation public function get reversed():Boolean
public function set reversed(value:Boolean):void
rotationProperties | property |
public static var rotationProperties:Object
A hash table specifying properties that should be affected by autoRotation.
snapping | property |
public var snapping:Boolean = false
If set to true, tweened values specified by snappingProperties will be rounded (snapped) before they are assigned to the target.
snappingProperties | property |
public static var snappingProperties:Object
A hash table specifying properties that should have their value rounded (snapped) before being applied. This can be toggled for each tween instance basis with the .snapping property.
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
ticker | property |
ticker:HybridTicker
[read-only]The currently active Ticker object.
Implementation public static function get ticker():HybridTicker
tweenPosition | property |
tweenPosition:Number
[read-only]
Returns the calculated absolute position in the tween. This is a deterministic value between 0 and duration calculated
from the current position based on the duration, repeat, reflect, and reversed properties.
For example, a tween with a position
of 5 on a tween with a duration of 3, and repeat set to true would have a tweenPosition of 2 (2 seconds into the first repeat).
The same tween with reflect set to true would have a tweenPosition of 1 (because it would be 2 seconds into the first repeat which is
playing backwards). With reflect and reversed set to true it would have a tweenPosition of 2.
Tweens with a position less than 0 will have a tweenPosition of 0. Tweens with a position greater than durationrepeat+1)
(the total length of the tween) will have a tweenPosition equal to duration.
public function get tweenPosition():Number
GTweeny | () | constructor |
public function GTweeny(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 {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.
|
beginning | () | method |
public function beginning():void
Jumps the tween to its beginning. This is the same as setting position=-delay
.
deleteProperty | () | method |
public function deleteProperty(name:String):Boolean
Removes a end value from the tween. This prevents the GTween instance from tweening the property.
Parametersname:String — The name of the end property to delete.
|
Boolean |
end | () | method |
public function end():void
Jumps the tween to its end. This is the same as setting position=(repeat+1)uration
.
getProperty | () | method |
public function getProperty(name:String):Number
Returns the destination value for the specified property if one exists.
Parametersname: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 a the target object while the tween was playing, you could call invalidate on it to force it to resume the tween with the new property values.
linearEase | () | method |
public static function linearEase(t:Number, b:Number, c:Number, d:Number):Number
The default easing function used by GTween.
Parameterst:Number |
|
b:Number |
|
c:Number |
|
d:Number |
Number |
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.
reverse | () | method |
public function reverse(suppressEvents:Boolean = true):void
Toggles the reversed property and inverts the current tween position. This will cause a tween to reverse playing visually. There is currently an issue with this functionality for tweens with a repeat of -1
ParameterssuppressEvents:Boolean (default = true ) — Indicates whether to suppress any events or callbacks that are generated as a result of the position change.
|
setPosition | () | method |
public function setPosition(position:Number, suppressEvents:Boolean = true):void
Sets the position of the tween. Using the position property will always suppress events and callbacks, whereas the setPosition method allows you to manually set the position and specify whether to suppress events or not.
Parametersposition:Number — The position to jump to in seconds or frames (depending on the timingMode).
|
|
suppressEvents:Boolean (default = true ) — Indicates whether to suppress events and callbacks generated from the change in position.
|
setProperties | () | method |
public function setProperties(properties:Object):void
Shorthand method for making multiple setProperty calls quickly. This removes any existing target property values on the tween.
Example: set x and y end values:
myGTween.setProperties({x:200, y:400});
properties:Object — An object containing end property values.
|
setProperty | () | method |
public function setProperty(name:String, value:Number):void
Sets the numeric end 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). Non-numeric values are ignored.
Parametersname:String — The name of the property to tween.
|
|
value:Number — The numeric end value (the value to tween to).
|
setTweenProperties | () | method |
public function setTweenProperties(properties:Object):void
Shortcut method for setting multiple properties on the tween instance 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:
initListener, completeListener, changeListener.
Example: This will set the duration, reflect, and nextTween properties of a tween, and add a listener for the complete event:
myTween.setTweenProperties({duration:4, reflect:true, nextTween:anotherTween, completeListener:completeHandlerFunction});
properties:Object |
change | event |
flash.events.Event
This event is dispatched each time the tween updates properties on its target. It will be dispatched each "tick" during the TWEEN.
complete | event |
flash.events.Event
Dispatched when a tween ends (its position equals its duration).
init | event |
flash.events.Event
Dispatched when a tween copies its initial properties and starts tweening. In tweens with a delay of 0, this event will fire immediately when it starts playing. In tweens with a delay set, this will fire when the delay state is ended, and the tween state is entered.