Core classes

Interfaces

Effect classes

  • BlurEffect
  • GlowEffect
  • ColorMatrixEffect
  • ColorTransformationEffect

Note: The reference section is still heavily under development. Please be patient while the CoreTween team is hard at work to finish the complete reference section for you. In the meantime, please feel free to browse the available sections. You can switch the implementation language on the left hand side menu.

Class Tween

org.coretween

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.Tween;
import org.coretween.easing.Expo;

var tween : Tween;
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut);
tween.start();
See also; Tweenable

Properties

NameDescription
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

START

This event is dispatched when the tween is started.

STOP

This event is dispatched when the tween is stopped.

PAUSE

This event is dispatched when the tween is paused.

RESUME

This event is dispatched when the tween is resumed.

REWIND

This event is dispatched when the tween is rewinded.

UPDATE_ENTER

This event is dispatched before the tween is being updated.

UPDATE_LEAVE

This event is dispatched before the tween is after updated.

COMPLETE

This event is dispatched before the tween is completed.

TIME

public static var TIME : uint
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.
import org.coretween.Tween;

tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut, delay, Tween.TIME);

FRAME

public static var FRAME : uint

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.

import org.coretween.Tween;

tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut, delay, Tween.FRAME);

tweening

public var 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.

See also; Tween:paused

paused

public var 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.

See also; Tween:tweening

position

public var 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.

target

public var 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.

values

public var 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.

See also; Tween:equations.

equations

public var equations : Object

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.

See also; Tween:values

duration

public var 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.

See also; Tween:delay

delay

public var delay : Number

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

public var 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 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:FRAME

Tween

public function Tween([target:Object], [properties:Object], [values:Object], [duration:Number], [equations:Object], [delay:Number], [type:uint]) : Tween

Use the Tween class constructor to construct a new Tween instance.

import org.coretween.Tween;
import org.coretween.easing.Expo;

var tween : Tween;
tween = new Tween(target_mc, { _x:250 }, 1.5, Expo.easeOut);
tween.start();
See also; Tween:target, Tween:properties, Tween:values, Tween:duration, Tween:equations, Tween:delay, Tween:type

start

public function start() : Boolean

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:pause

stop

public function stop() : Boolean

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:start

pause

public function pause([pause:Boolean]) : void

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

See also; Tween:resume

resume

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; Tween:pause

rewind

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; Tween:start

update

public function update() : 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.