Constructors

Properties

Methods

Events

Tween class

com.senocular.Tween

 

 

 

Overview

Usage

class com.senocular.Tween

Description

The Tween class is used to create tweens or in-between values providing a beginning and ending point, usually numbers, over a period of time measured in steps. This is typically used for animation. The events provided are simple callbacks used like onPress for buttons.

Constructors

 

Tween

Usage

function Tween(begin:Number, end:Number, steps:Number, behavior:String, smooth:Boolean, ease:Function, round:Boolean, clamp:Boolean)

Description

Constructor: Creates a new Tween instance. New tween instances do not start tweening until you explicitly instruct them to.

Parameters

begin
(Optional) The starting value of the tween. Default: 0.
end
(Optional) The ending value of the tween. Default: 1.
steps
(Optional) The number of steps needed to complete a tween. Default: 100.
behavior
(Optional) "loop", "yoyo", or "default" behavior. Default: "default".
smooth
(Optional) Smooths looped and yoyoed tweens. Default: false.
ease
(Optional) Ease function. Default: undefined.
round
(Optional) Round tween value. Default: false.
clamp
(Optional) Clamp tween value between begin and end. Default: false.

Properties

 

begin

Usage

public var begin:Number

Description

The starting value of the tween.

Default

0
 

end

Usage

public var end:Number

Description

The ending value of the tween.

Default

1
 

steps

Usage

public var steps:Number

Description

The number of steps needed to complete a tween.

Default

100
 

currentStep

Usage

public var currentStep:Number

Description

The current step in the tween. This will be between 0 and steps.

Default

0
 

value

Usage

public var value:Number

Description

The value of the tween between begin and end.

Default

0
 

progress

Usage

public var progress:Number

Description

The progress of the tween in percent (0-1) not including ease.

Default

0
 

easeProgress

Usage

public var easeProgress:Number

Description

The progress of the tween in percent (usually 0-1) including ease.

Default

0
 

ease

Usage

public var ease:Function

Description

The function used to ease the tween progress.
 

direction

Usage

public var direction:Number

Description

Direction of movement, 1 for forward, -1 for reverse.

Default

1
 

enabled

Usage

public var enabled:Boolean

Description

Determines if tween is enabled. If not enabled, tween steps result in no change.

Default

true
 

behavior

Usage

public var behavior:String

Description

Determines if tween loops or yoyos or behaves normally. Acceptable values are "loop" and "yoyo". Anything else results in a normal tween ending after reaching end.

Default

"default"
 

event

Usage

public var event:String

Description

Identifies the automatic tween. Values can be "enterFrame" or "interval".

Default

"enterFrame"
 

smooth

Usage

public var smooth:Boolean

Description

When true, smooths looped and yoyoed tweens. Smoothing prevents repetition of tween values at their end points alloing for smoother transitions.

Default

false
 

round

Usage

public var round:Boolean

Description

When true, the tween rounds its resulting value each step

Default

false
 

clamp

Usage

public var clamp:Boolean

Description

When true, the tween's value never goes below begin and never above end.

Default

false

Methods

 

step

Usage

public function step(Void):Number

Description

Takes the tween to the next step of its tweening process updating all tween properties to reflect the new position. This can be called manually or automatically using startEnterFrame or startInterval.

Returns

The current value associated with the Tween instance
 

update

Usage

public function update(progress:Number):Number

Description

Reverses the direction of a tween

Parameters

progress
(Optional) A percentage progress value to update the tween with

Returns

The current value associated with the Tween instance
 

reverse

Usage

public function reverse(backwards:Boolean):Void

Description

Reverses the direction of a tween

Parameters

backwards
(Optional) If true forces a tween to play backwards (in reverse). If true the tween's direction is forced forward. Omitting the value toggles the direction.

Returns

Nothing.
 

reset

Usage

public function reset(Void):Void

Description

Resets a tween to its default position and direction

Returns

Nothing.
 

addTarget

Usage

public function addTarget(target:Object, property:String, begin, end, interpolate:Function):Void

Description

Adds a target-property combination to be affected by the tween

Parameters

target
The object the tween will affect
property
The property of the object the tween's value is being assigned. if this represents a function, the function is called with the tween value passed to it as opposed to the property being assigned to equal the tween value
begin
(Optional) Starting value for the property if different from the tween's
end
(Optional) Ending value for the property if different from the tween's
interpolate
(Optional) A function to be used in interpolating the begin and end values if not numeric (if the begin and end values were points, for example). The format of this function is interpolate(end, begin, percent) - similar to Flash 8's Point.interpolate; the higher the percent (tween progress), the closer to end.

Returns

Nothing.
 

removeTarget

Usage

public function removeTarget(target:Object, property:String):Boolean

Description

Removes a target-property combination from a tween's affect that was added with addTarget

Parameters

target
The target object to be removed
property
The property relating to the target-property combination which is to be removed to it as opposed to the property being assigned to equal the tween value

Returns

True or false depending on whether or not removal was successful
 

startEnterFrame

Usage

public function startEnterFrame(skip:Number):Void

Description

Starts and automatic tween using an onEnterFrame event

Parameters

skip
The number of frames to skip every frame before applying a tween step. This lets you slow tweens down to a rate that's slower than the FPS of the movie. 0 skips no frames, 1 tweens every other frame, 2 skips 2 frames etc.

Returns

Nothing.
 

startInterval

Usage

public function startInterval(milliseconds:Number):Void

Description

Starts and automatic tween using a timed interval event

Parameters

milliseconds
(Optional) The number of milliseconds to play each tween step. Default: 1000.

Returns

Nothing.
 

start

Usage

public function start(Void):Void

Description

Starts and automatic tween using the last tween type used (enterFrame or interval). If startEnterFrame or startInterval has not been used prior to start(), startEnterFrame is implied calling a tween step every frame.

Returns

Nothing.
 

stop

Usage

public function stop(Void):Void

Description

Stops an automatic tween from continuing. Use startEnterFrame, startInterval, or start to resume the tween.

Returns

Nothing.

Events

 

onStart

Usage

public var onStart:Function

Description

Called when an automatic tween is started
 

onStop

Usage

public var onStop:Function

Description

Called when an automatic tween is stopped
 

onComplete

Usage

public var onComplete:Function

Description

Called when an automatic tween is not looping or yoyoing and completes
 

onLoop

Usage

public var onLoop:Function

Description

Called when a tween loops
 

onYoyo

Usage

public var onYoyo:Function

Description

Called when a tween Changes direction during a yoyo
 

onStep

Usage

public var onStep:Function

Description

Called during each step