Timeline

EventDispatcher
Timeline

The ‘Timeline’ class simulates the timeline paradox by presenting a similar API to create and control tweens.

Summary
TimelineThe ‘Timeline’ class simulates the timeline paradox by presenting a similar API to create and control tweens.
Constants
DEFAULT_RENDER_METHODConfigures the default render method to use for rendering tweens.
DEFAULT_FRAME_RATEConfigures the default frame rate for timelines.
DEFAULT_LOOPConfigures the default loop setting.
Variables
m_objRendererPrevHolds an instance of the renderer object for rendering playback in reverse.
m_objRendererNextHolds an instance of the renderer object for rendering playback forwards.
m_uRenderMethodStores the render method being used to render this object’s tweens.
m_uFrameRateThe frame rate for this timeline to play at.
m_nRefreshRateThe necessary refresh rate to achieve the desired frame rate.
m_objTweenStackA stack for storing all tweens in this timeline.
m_uFrameThe current frame the playhead of this timeline is at.
m_uLengthThe length (in frames) of this timeline.
m_bLoopDetermines whether or not this timeline loops when the last frame is finished.
Functions
TimelineConstructor.
onPrevFrameEFCalled by the renderer when playing in reverse using the ‘RenderMethod.ENTER_FRAME’ render method.
onNextFrameEFCalled by the renderer when playing forwards using the ‘RenderMethod.ENTER_FRAME’ render method.
onPrevFrameTCalled by the renderer when playing in reverse using the ‘RenderMethod.TIMER’ render method.
onNextFrameTCalled by the renderer when playing forwards using the ‘RenderMethod.TIMER’ render method.
setFrameRateSets the frame rate this timeline plays at.
addTweenAdds a new tween to this timeline.
playPlays this timeline from the current frame.
playReversePlays this timeline in reverse from the current frame.
stopStops this timeline at the current frame.
gotoAndPlayMoves the playhead to the desired frame and then plays from there.
gotoAndPlayReverseMoves the playhead to the desired frame and then plays in reverse from there.
gotoAndStopMoves the playhead to the desired frame and then stops.
prevFrameMove the playhead backwards one frame.
nextFrameMove the playhead forwards one frame.
Properties
lengthReturns the length (in frames) of this timeline.
loopGets the current loop setting.
loopSets whether the playhead loops back to the first frame and continues playing when the last frame is reached or not.
Functions
disposePerforms any appropriate clean-up tasks for garbage collection such as removing event listeners, setting object references to ‘null’, etc.
initInitializes this object.
setFrameSets the current frame of the playhead.
computeFrameDataComputes the necessary frame data for each tween.
renderLoops through the tween stack and renders the current frame of each tween.

Constants

DEFAULT_RENDER_METHOD

protected const DEFAULT_RENDER_METHOD: uint

Configures the default render method to use for rendering tweens. 

The default value ‘2’ is RenderMethod.TIMER.  This is done because the ‘RenderMethod’ class is not available at the time this is compiled.

See Also

com.boostworthy.animation.rendering.RenderMethod

DEFAULT_FRAME_RATE

protected const DEFAULT_FRAME_RATE: Number

Configures the default frame rate for timelines.  This is only used if the render method is ‘RenderMethod.TIMER’.  ‘RenderMethod.ENTER_FRAME’ uses the SWF file’s frame rate.

See Also

com.boostworthy.animation.rendering.RenderMethod

DEFAULT_LOOP

protected const DEFAULT_LOOP: Boolean

Configures the default loop setting.

Variables

m_objRendererPrev

protected var m_objRendererPrev: Renderer

Holds an instance of the renderer object for rendering playback in reverse.

m_objRendererNext

protected var m_objRendererNext: Renderer

Holds an instance of the renderer object for rendering playback forwards.

m_uRenderMethod

protected var m_uRenderMethod: uint

Stores the render method being used to render this object’s tweens.

m_uFrameRate

protected var m_uFrameRate: uint

The frame rate for this timeline to play at.

m_nRefreshRate

protected var m_nRefreshRate: Number

The necessary refresh rate to achieve the desired frame rate.

m_objTweenStack

protected var m_objTweenStack: TweenStack

A stack for storing all tweens in this timeline.

m_uFrame

protected var m_uFrame: uint

The current frame the playhead of this timeline is at.

m_uLength

protected var m_uLength: uint

The length (in frames) of this timeline.

m_bLoop

protected var m_bLoop: Boolean

Determines whether or not this timeline loops when the last frame is finished.

Functions

Timeline

public function Timeline(uRenderMethod: uint = DEFAULT_RENDER_METHOD,
nFrameRate: Number = DEFAULT_FRAME_RATE)

Constructor.

Parameters

param uRenderMethod The render method to use for rendering tweens.
param nFrameRate The frame rate for the timeline to play at.  This is only used if ‘RenderMethod.TIMER’ is used as the render method. 

See Also

com.boostworthy.animation.rendering.RenderMethod, DEFAULT_RENDER_METHOD, DEFAULT_FRAME_RATE

onPrevFrameEF

protected function onPrevFrameEF(objEvent: Event):void

Called by the renderer when playing in reverse using the ‘RenderMethod.ENTER_FRAME’ render method.

Parameters

param objEvent An object containing information about the enter frame event. 

See Also

com.boostworthy.animation.rendering.RenderMethod

onNextFrameEF

protected function onNextFrameEF(objEvent: Event):void

Called by the renderer when playing forwards using the ‘RenderMethod.ENTER_FRAME’ render method.

Parameters

param objEvent An object containing information about the enter frame event. 

See Also

com.boostworthy.animation.rendering.RenderMethod

onPrevFrameT

protected function onPrevFrameT(objEvent: TimerEvent):void

Called by the renderer when playing in reverse using the ‘RenderMethod.TIMER’ render method.

Parameters

param objEvent An object containing information about the timer event. 

See Also

com.boostworthy.animation.rendering.RenderMethod

onNextFrameT

protected function onNextFrameT(objEvent: TimerEvent):void

Called by the renderer when playing forwards using the ‘RenderMethod.TIMER’ render method.

Parameters

param objEvent An object containing information about the timer event. 

See Also

com.boostworthy.animation.rendering.RenderMethod

setFrameRate

public function setFrameRate(nFrameRate: Number):void

Sets the frame rate this timeline plays at.

Parameters

param nFrameRate The frame rate for the timeline to play at. 

addTween

public function addTween(objTween: ITween):void

Adds a new tween to this timeline.

Parameters

param objTween The tween to add to this timeline. 

play

public function play():void

Plays this timeline from the current frame.

playReverse

public function playReverse():void

Plays this timeline in reverse from the current frame.

stop

public function stop():void

Stops this timeline at the current frame.

gotoAndPlay

public function gotoAndPlay(uFrame: uint):void

Moves the playhead to the desired frame and then plays from there.

Parameters

param uFrame The frame to move the playhead to. 

gotoAndPlayReverse

public function gotoAndPlayReverse(uFrame: uint):void

Moves the playhead to the desired frame and then plays in reverse from there.

Parameters

param uFrame The frame to move the playhead to. 

gotoAndStop

public function gotoAndStop(uFrame: uint):void

Moves the playhead to the desired frame and then stops.

Parameters

param uFrame The frame to move the playhead to. 

prevFrame

public function prevFrame():void

Move the playhead backwards one frame.

nextFrame

public function nextFrame():void

Move the playhead forwards one frame.

Properties

length

public function get length():Number

Returns the length (in frames) of this timeline.

Returns

The length (in frames) of this timeline. 

loop

public function get loop():Boolean

Gets the current loop setting.

Returns

The current loop setting. 

loop

public function set loop(bLoop: Boolean):void

Sets whether the playhead loops back to the first frame and continues playing when the last frame is reached or not.

Parameters

param bLoop The new loop setting. 

Functions

dispose

public function dispose():void

Performs any appropriate clean-up tasks for garbage collection such as removing event listeners, setting object references to ‘null’, etc.

init

protected function init(uRenderMethod: uint,
nFrameRate: Number):void

Initializes this object.

Parameters

param uRenderMethod The render method to use for rendering tweens.
param nFrameRate The frame rate for the timeline to play at.  This is only used if ‘RenderMethod.TIMER’ is used as the render method. 

See Also

com.boostworthy.animation.rendering.RenderMethod

setFrame

protected function setFrame(uFrame: Number):void

Sets the current frame of the playhead.

Parameters

param uFrame The frame to move the playhead to. 

computeFrameData

protected function computeFrameData(uFirstFrame: uint,
uLastFrame: uint):void

Computes the necessary frame data for each tween.

Parameters

param uFirstFrame The first frame to compute.
param uLastFrame The last frame to compute. 

render

protected function render(bIsReverse: Boolean = false):void

Loops through the tween stack and renders the current frame of each tween.

Parameters

param bIsReverse A parameter which will force the stack to be rendered in reverse if necessary. 
The ‘IDisposable’ interface defines a common interface for all objects to encorporate garbage collection.
Extends the Timeline class with methods to get and remove tweens and dispose of the whole timeline.
protected const DEFAULT_RENDER_METHOD: uint
Configures the default render method to use for rendering tweens.
protected const DEFAULT_FRAME_RATE: Number
Configures the default frame rate for timelines.
protected const DEFAULT_LOOP: Boolean
Configures the default loop setting.
protected var m_objRendererPrev: Renderer
Holds an instance of the renderer object for rendering playback in reverse.
protected var m_objRendererNext: Renderer
Holds an instance of the renderer object for rendering playback forwards.
protected var m_uRenderMethod: uint
Stores the render method being used to render this object’s tweens.
protected var m_uFrameRate: uint
The frame rate for this timeline to play at.
protected var m_nRefreshRate: Number
The necessary refresh rate to achieve the desired frame rate.
protected var m_objTweenStack: TweenStack
A stack for storing all tweens in this timeline.
protected var m_uFrame: uint
The current frame the playhead of this timeline is at.
protected var m_uLength: uint
The length (in frames) of this timeline.
protected var m_bLoop: Boolean
Determines whether or not this timeline loops when the last frame is finished.
public function Timeline(uRenderMethod: uint = DEFAULT_RENDER_METHOD,
nFrameRate: Number = DEFAULT_FRAME_RATE)
Constructor.
protected function onPrevFrameEF(objEvent: Event):void
Called by the renderer when playing in reverse using the ‘RenderMethod.ENTER_FRAME’ render method.
protected function onNextFrameEF(objEvent: Event):void
Called by the renderer when playing forwards using the ‘RenderMethod.ENTER_FRAME’ render method.
protected function onPrevFrameT(objEvent: TimerEvent):void
Called by the renderer when playing in reverse using the ‘RenderMethod.TIMER’ render method.
protected function onNextFrameT(objEvent: TimerEvent):void
Called by the renderer when playing forwards using the ‘RenderMethod.TIMER’ render method.
public function setFrameRate(nFrameRate: Number):void
Sets the frame rate this timeline plays at.
public function addTween(objTween: ITween):void
Adds a new tween to this timeline.
public function play():void
Plays this timeline from the current frame.
public function playReverse():void
Plays this timeline in reverse from the current frame.
public function stop():void
Stops this timeline at the current frame.
public function gotoAndPlay(uFrame: uint):void
Moves the playhead to the desired frame and then plays from there.
public function gotoAndPlayReverse(uFrame: uint):void
Moves the playhead to the desired frame and then plays in reverse from there.
public function gotoAndStop(uFrame: uint):void
Moves the playhead to the desired frame and then stops.
public function prevFrame():void
Move the playhead backwards one frame.
public function nextFrame():void
Move the playhead forwards one frame.
public function get length():Number
Returns the length (in frames) of this timeline.
public function get loop():Boolean
Gets the current loop setting.
public function dispose():void
Performs any appropriate clean-up tasks for garbage collection such as removing event listeners, setting object references to ‘null’, etc.
protected function init(uRenderMethod: uint,
nFrameRate: Number):void
Initializes this object.
protected function setFrame(uFrame: Number):void
Sets the current frame of the playhead.
protected function computeFrameData(uFirstFrame: uint,
uLastFrame: uint):void
Computes the necessary frame data for each tween.
protected function render(bIsReverse: Boolean = false):void
Loops through the tween stack and renders the current frame of each tween.
Close