Core classes
Interfaces
Effect classes
- BlurEffect
- GlowEffect
- ColorMatrixEffect
- ColorTransformationEffect
Class Tween
Object
|
+--Tween
public class Tween implements Tweenable
Tween class represents a single tween object. It keeps track of all timing and state variables necessary to execute the tween.
import org.coretween.easing.Expo;
var tween : Tween;
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut);
tween.start();
Properties
| Name | Description |
| TIME : uint | A constant that is used to indicate time based rendering. |
| FRAME : uint | A constant that is used to indicate frame based rendering. |
| tweening : Boolean | |
| paused : Boolean | |
| position : Number | |
| target : Object | |
| values : Object | |
| equations : Object | |
| duration : Number | |
| delay : Number | |
| type : uint |
Methods
Events
| Name | Description |
| START | |
| STOP | |
| PAUSE | |
| RESUME | |
| REWIND | |
| UPDATE_ENTER | |
| UPDATE_LEAVE | |
| COMPLETE |
TIME
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut, delay, Tween.TIME);
FRAME
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.
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut, delay, Tween.FRAME);
tweening
[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.
See also; Tween:pausedpaused
[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.
See also; Tween:tweeningposition
[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.
target
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.
values
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:
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:
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.
See also; Tween:equations.equations
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.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.
See also; Tween:valuesduration
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.
See also; Tween:delaydelay
Sets or returns the delay for the tween. The 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.
See also; Tween:duration.type
Sets or returns the rendering method for the tween. There are two distinc rendering methods available in CoreTween;
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 number 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.
See also; Tween:TIME, Tween:FRAMETween
Use the Tween class constructor to construct a new Tween instance.
import org.coretween.easing.Expo;
var tween : Tween;
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut);
tween.start();
start
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; Tween:target, Tween:properties, Tween:values, Tween:duration, Tween:equations, Tween:delay, Tween:type Tween:pausestop
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; Tween:startpause
Pauses a tween. If a tween is already paused the tween will resume. Calling this method will dispatch an onPause event.
See also; Tween:resumeresume
Resumes a paused tween. The resume method does not affect a none paused tween. Calling this method will dispatch an RESUME event.
See also; Tween:pauserewind
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; Tween:startupdate
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.

