Packageorg.coretween
Classpublic class Tween
InheritanceTween Inheritance flash.events.EventDispatcher
Implements Tweenable
Subclasses Effect

The Tween class represents a single tween object. It keeps track of all timing and state variables necessary to execute the tween.



Public Properties
 PropertyDefined By
  delay : Number
Sets or gets the delay of a Tween object.
Tween
  duration : Number
Sets or returns the duration of the Tween.
Tween
  equations : Object
[write-only] Sets or returns the equations that the Tween object is tweening with.
Tween
  FRAME : uint = 2
[static] Use this constant to specify if frame based rendering is preferred when executing the tween.
Tween
  loop : Boolean
Indicates whether the Tween object loops or not.
Tween
  paused : Boolean
[read-only] Returns the current paused state of the Tween object.
Tween
  position : Number
[read-only] Returns the percentage that the tween has completed.
Tween
  target : Object
Sets or returns the target the Tween object is operating on.
Tween
  TIME : uint = 1
[static] Use this constant to specify if time based rendering is preferred when executing the tween.
Tween
  tweening : Boolean
[read-only] Returns the current tweening state of the Tween.
Tween
  type : uint
Sets or returns the rendering method for the tween.
Tween
  values : Object
Sets or returns the properties to tween and the values to tween to for the Tween object to operate on.
Tween
Public Methods
 MethodDefined By
  
Tween(target:Object = null, values:Object = null, duration:Number = 0, equations:Object = null, delay:Number = 0, loop:Boolean = false, type:uint = 0xffff)
The Tween constructor creates a new Tween object.
Tween
  
pause(... args):void
Pauses a tween.
Tween
  
resume():void
Resumes a paused tween.
Tween
  
rewind():void
Rewinds a tween to its starting position.
Tween
  
start():void
Starts a tween.
Tween
  
stop():void
Stops the tween.
Tween
  
update(timeCurrent:Number):void
Calling the update method will update the visual apearance of the tween.
Tween
Property Detail
delayproperty
delay:Number

Sets or gets the delay of a Tween object. Delay is always specified in seconds. To specify half a second of delay use a value of 0.5 for one second use 1.0 etc.


Implementation
    public function get delay():Number
    public function set delay(value:Number):void

See also

durationproperty 
duration:Number

Sets or returns the duration of the Tween. The duration is always specified in seconds. To specify half a second of time use a value of 0.5 for one second use 1.0 etc.


Implementation
    public function get duration():Number
    public function set duration(value:Number):void
equationsproperty 
equations:Object  [write-only]

Sets or returns the equations that the Tween object is tweening with. The value for this property can be either a reference to a single equation function, or an Array specifying a series of equations that match the number of properties the Tween object is operating on.

When an Array of equations is specified, then the order in which the equations are listed must correspond to the order in which the [property]:[value] pairs are set with the Tween values property. The following example shows the different ways in which the equations property can be set.

import org.coretween.Tween; import org.coretween.easing.Expo; import org.coretween.easing.Elastic; tween.equations = Expo.easeOut; tween.equations = [Expo.easeOut, Expo.easeIn]; tween.equations = [Expo.easeOut, { ease:Back.easeOut, a:0.5, b:1.5 } ];

When requesting the value of this property, an Array object is returned. Even if only a single equation has been specified.


Implementation
    public function set equations(value:Object):void

See also

FRAMEproperty 
public static var FRAME:uint = 2

Use this constant to specify if frame based rendering is preferred when executing the tween. Frame based rendering can increase performance (decrease CPU overhead). Frame based rendering is the default setting if no rendering method is specified.

See also

loopproperty 
loop:Boolean

Indicates whether the Tween object loops or not.


Implementation
    public function get loop():Boolean
    public function set loop(value:Boolean):void
pausedproperty 
paused:Boolean  [read-only]

Returns the current paused state of the Tween object. When this property is set to true the Tween object is in a paused state. Whenever this property is set to true then also the tweening property will be set to true as well.


Implementation
    public function get paused():Boolean

See also

positionproperty 
position:Number  [read-only]

Returns the percentage that the tween has completed. When a delay is set then this time is taken into account as well. So, imagine a tween with a duration of 4 seconds and a delay of 2 seconds then the whole tween takes 6 seconds to complete. The position is the percentage of the total time spend including the delayed time.


Implementation
    public function get position():Number
targetproperty 
target:Object

Sets or returns the target the Tween object is operating on. The target can be any valid Object with a numeric number for the Tween object to operate on.


Implementation
    public function get target():Object
    public function set target(value:Object):void
TIMEproperty 
public static var TIME:uint = 1

Use this constant to specify if time based rendering is preferred when executing the tween. Time based rendering can increase the smoothness factor with which the tween is performed.

See also

tweeningproperty 
tweening:Boolean  [read-only]

Returns the current tweening state of the Tween. This property is set to true when the Tween object is currently tweening. This means that when a Tween is in a paused state this property can still return true if the tween was not fully completed.


Implementation
    public function get tweening():Boolean

See also

typeproperty 
type:uint

Sets or returns the rendering method for the tween. There are two distinc rendering methods available in CoreTween;

Tween.FRAME Tween.TIME

Frame based rendering (default); When a tween's type is set to frame based rendering, a new frame within the tween will be generated with the frames per second (fps) the main movie is set to. So, if a movie is set to 12 fps then a new tween frame will only be generated 12 times a second. Frame based rendering is the default setting because it is the most native to the Flash Player's behaviour. However, keep in mind that the smoothness of a tween is very much depended on the n umber of frames calculated within a second. The higher the fps the smoother a tween will be.

Time based rendering; When a tween's type is set to time based rendering, a new frame is calculated based on CoreTween's internal fps rather than the main movie fps value. The default internal fps is set to 60. This means that when using time based rendering with the default internal fps, a new frame is calculated 60 times a second. Keep in mind that this heavily depends on the CPU the Flash Player is running on and the amount of screen area that needs to be updated. However, when using time based rendering you might achieve much smoother animations then with frame based rendering because time based rendering is completely independent from the global frame rate. It's best to use time based rendering for small animations that do not impact the CPU a great deal.


Implementation
    public function get type():uint
    public function set type(value:uint):void

See also

valuesproperty 
values:Object

Sets or returns the properties to tween and the values to tween to for the Tween object to operate on. This value can be set through the Tween class constructor or can be set (or changed) after the Tween object has been constructed. The general syntax for the values property is:

{ [property]:[value] }

Where [property] is the property to operate on and [value] is the target value that the property will have when to tween process is completed. More than one [property]:[value] pair can be supplied. E.g:

{ [property]:[value], [property]:[value] }

For new values to effectively be set, the values properties of the Tween object must be assigned. E.g. values that are assigned through an associative array technique are not regarded as set values and will not included in the tween process.


Implementation
    public function get values():Object
    public function set values(value:Object):void

See also

Constructor Detail
Tween()Constructor
public function Tween(target:Object = null, values:Object = null, duration:Number = 0, equations:Object = null, delay:Number = 0, loop:Boolean = false, type:uint = 0xffff)

The Tween constructor creates a new Tween object.

Parameters
target:Object (default = null) — The target to operate on.
 
values:Object (default = null)
 
duration:Number (default = 0)
 
equations:Object (default = null)
 
delay:Number (default = 0)
 
loop:Boolean (default = false)
 
type:uint (default = 0xffff)

See also

Method Detail
pause()method
public function pause(... args):void

Pauses a tween. If a tween is already paused the tween will resume. Calling this method will dispatch an onPause event.

Parameters

... args

See also

resume()method 
public function resume():void

Resumes a paused tween. The resume method does not affect a none paused tween. Calling this method will dispatch an RESUME event.

See also

rewind()method 
public function rewind():void

Rewinds a tween to its starting position. The rewind method resets the tween to its starting position and leaves the tween in a stopped state. The tween can only be started by calling the start method. Calling this method will dispatch an REWIND event.

See also

start()method 
public function start():void

Starts a tween. When starting a tween make sure that all necessary properties are set. These include the target, properties, values, duration and equations. The delay and type properties are optional. When a tween has been stopped before it was ended and the start method is used to restart the tween, the tween will be reset to begin from its original start position. To pause a tween use the pause method instead.

Calling this method will dispatch an START event when the tween is successfully started. This method returns true if the tween was successfully started otherwise it will return false.

See also

stop()method 
public function stop():void

Stops the tween. Stopping the tween doesn't rewind the tween to the start. To rewind the tween use the rewind method instead. Calling this method will dispatch an STOP event. Returns true when successfully stopped otherwise false.

See also

update()method 
public function update(timeCurrent:Number):void

Calling the update method will update the visual apearance of the tween. It is not necessary to call this method manually since its called by the TweenManager that keeps track of the update process. Calling the update method will trigger an UPDATE_ENTER event before the tween is updated and an UPDATE_LEAVE event after the tween has been updated.

Parameters

timeCurrent:Number — The current time in milliseconds.