BiComponentAnimation

This class is the basis for all animations. Typically you don't work with this class directly, but instead use one of it's subclasses. You will need to use some methods here, common to all animations. Such as start and stop for example. If you want to create a completely new type of animation, however you need to be aware of the specifics of this class. BiComponentAnimation generates values in a specified range a certain number of times per second. This is useded to drive the value of properties to create animation. It is possible to have several different value ranges which each can have various properties like speed and acceleration behavior. Predefined acceleration curves exist to simulate acceleration and deceleration. To animate, you create a BiComponentAnimation object and setup parameters as needed. You then register BiComponents with it. When you start the animation, all registered BiComponents will be animated in the same way. If you need different animation behaviors for different BiComponents you will have to create different BiComponentAnimation objects with different properties.

This class extends BiEventTarget and therefore all methods and fields available for BiEventTarget are also available for BiComponentAnimation .

Constructor

new BiComponentAnimation ( [ oComp [ ,nFrameRate [ ,bAutoStart ] ] ] )

Parameters

Name Type Optional Default Descripton
oComp BiComponent checked A BiComponent to animate
nFrameRate Number checked BiFpsGenerator.DEFAULT_FRAME_RATE How many frames per second that the animation should use
bAutoStart Boolean checked false If the animation should start immediately

Properties

Name Type get set Descripton
autoStart Boolean checked If animation should start automatically once the first component is added.
currentAnimationRange Number : Which animation stage is currently active. The first stage is numbered 0. checked Finds the index number of the active animation stage.
currentPosition Number : Current position in milliseconds. checked Returns, in milliseconds, how far the animation has progressed in the active aniamtion range.
frameRate Number : Current frame rate, Frames Per Second. checked checked Current frame rate.
generator BiFpsGenerator checked checked Accesses the frame generator that drives the animation.
looping Boolean checked Turns looping on.

Methods

Name Description
addComponent Adds a BiComponent. Added components will be animated. When the first component is added, it will immediately start animating if started or if autostart is true.
clearAllAnimationRanges Removes all animation ranges
dispose Call this when you are done with this object, to reclaim memory.
getAnimationRange Retrieves an animation range object of certain index representing a certain stage of the animation.
onFrameProgression Override this to add customized behavior when upon frameprogression.
onMax Override to be notified when the max position in the range has been reached.
pushAnimationRange Adds a value range that will be animated, to the stack.
removeAnimationRange Removes the last added BiAnimationRange object.
removeComponent Removes the component rendering it unaffected by this animator.
rewind Restarts the animation from the beginning. If the animation consists of several stages, all stages will be rewinded.
start Tells the generator to start the frame animation loop.
stop Tells the generator to stop the frame animation loop.

Events

Name Type Bubbles Descripton
animationend BiFrameProgressionEvent Fired when the animation has played through completely. Once per loop iteration if looping is active.
frameprogression BiFrameProgressionEvent Fired upon every new frame

Static Methods

None.

Static Fields

Name Type Descripton
CONSTANT_SPEED Number No acceleration will occur
FAST_TO_SLOW Number Starts fast and decelerates towards the end
SLOW_TO_FAST Number Starts slowly and accelerates until the end of the range is reached
SLOW_TO_SLOW Number Starts at a slow speed, reaches high speed, decelerated towards end

Remarks

By not specifying the frame rate, the global BiFpsGenerator will be used. This is generally preferred as it saves the system from creating a new unique generator. Animationend is dispatched after the last frameprogression event. Adding a component activates autostart. Once animation has started, autostart will be set to false. Use the BiFpsGenerator to change the frame rate of the animation after it's been created. Tip: Think of the different ranges as stages that we must go through. BiAnimationRange objects are stored in a stack. To correctly dispose your animation, you should listen for the animationend event and call dispose there.

Method Details

addComponent

Adds a BiComponent. Added components will be animated. When the first component is added, it will immediately start animating if started or if autostart is true.

Syntax

object.addComponent
 (
 oComp
 )
 

Parameters

Name Type Optional Default Descripton
oComp BiComponent The given component will be animated.

Return Type

void

clearAllAnimationRanges

Removes all animation ranges

Syntax

object.clearAllAnimationRanges
 (
 
 )
 

Parameters

No arguments.

Return Type

void

dispose

Call this when you are done with this object, to reclaim memory.

Syntax

object.dispose
 (
 
 )
 

Parameters

No arguments.

Return Type

void

getAnimationRange

Retrieves an animation range object of certain index representing a certain stage of the animation.

Syntax

object.getAnimationRange
 (
 nIndex
 )
 

Parameters

Name Type Optional Default Descripton
nIndex Number The number of the animation range. 0 for first.

Return Type

BiAnimationRange Data for a certain stage of the animation

onFrameProgression

Override this to add customized behavior when upon frameprogression.

Syntax

object.onFrameProgression
 (
 pos
 )
 

Parameters

Name Type Optional Default Descripton
pos Number The generated value. A positive value.

Return Type

void

onMax

Override to be notified when the max position in the range has been reached.

Syntax

object.onMax
 (
 
 )
 

Parameters

No arguments.

Return Type

void

pushAnimationRange

Adds a value range that will be animated, to the stack.

Syntax

object.pushAnimationRange
 (
 oRange
 )
 

Parameters

Name Type Optional Default Descripton
oRange BiAnimationRange Object that contains start, end, time acceleration behavior etc.

Return Type

void

removeAnimationRange

Removes the last added BiAnimationRange object.

Syntax

object.removeAnimationRange
 (
 
 )
 

Parameters

No arguments.

Return Type

void

removeComponent

Removes the component rendering it unaffected by this animator.

Syntax

object.removeComponent
 (
 oComp
 )
 

Parameters

Name Type Optional Default Descripton
oComp BiComponent Unregisteres component affected by animator

Return Type

void

rewind

Restarts the animation from the beginning. If the animation consists of several stages, all stages will be rewinded.

Syntax

object.rewind
 (
 
 )
 

Parameters

No arguments.

Return Type

void

start

Tells the generator to start the frame animation loop.

Syntax

object.start
 (
 
 )
 

Parameters

No arguments.

Return Type

void

stop

Tells the generator to stop the frame animation loop.

Syntax

object.stop
 (
 
 )
 

Parameters

No arguments.

Return Type

void