BiLocationAnimator

Animates the location of BiComponents to create movement. This class has a repository of motion paths. A motion path is created by setting start and end screen coordinates. Objects will be animated between these in a straight line. Motion paths are stored in a stack where the first motion path, called the default motion path, is created upon construction. The default motion path can be changed and modified dynamically via getter/setter function, whereas additional motion paths can only be either added or removed. For each motion path you have independent control over speed and acceleration algorithms.
By pushing more motion paths onto the stack you can make the object animate around multiple positions on the screen and create complex movement.
To animate a component, you create the animator object and add componen(s) to it, then start the animation.

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

Constructor

new BiLocationAnimator ( [ x1 [ ,y1 [ ,x2 [ ,y2 [ ,nSpeed [ ,bLoop [ ,nAccType [ ,oComp [ ,nFrameRate [ ,bAutoStart ] ] ] ] ] ] ] ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
x1Numberchecked0 Horizontal screen start position
y1Numberchecked0 Vertical screen start position
x2Numberchecked0 Horizontal screen end position
y2Numberchecked0 Vertical screen end position
nSpeedNumberchecked500 Duration of animation, measured in milliseconds
bLoopBooleancheckedfalse Loops animation endlessly
nAccTypeNumbercheckedBiComponentAnimation.CONSTANT_SPEED Acceleration type/behavior
oCompBiComponentcheckedA component to animate
nFrameRateNumbercheckedBiFpsGenerator.DEFAULT_FRAME_RATE Sets a specific frame rate for this animation
bAutoStartBooleancheckedfalse If the animation should start immediately

Properties

NameTypegetsetDescripton
accTypevoidcheckedChanges the acceleration type for the default motion path. Use one of the acceleration constants defined in BiComponentAnimation
fromBottomvoidcheckedSets the animation start y position relative to either a from-component, if set. Otherwise bottom relates to the browser's viewport. Setting bottom cancels top.
fromComponentvoidcheckedInstead of using absolute window positions, you can position the animation relative another components position. By setting the from-component you specify another BiComponent whos location will be used for the animation's start state. If the from-component's location or size is changed, the animation will update dynamically. By default the top left corner of the from-component will be this animation's start x/y.
fromLeftvoidcheckedSets the animation start x position relative to either a from-component, if set. Otherwise left relates to the browser's viewport. Setting left cancels right.
fromRightvoidcheckedSets the animation start x position relative to either a from-component, if set. Otherwise right relates to the browser's viewport. Setting right cancels left.
fromTopvoidcheckedSets the animation start y position relative to either a from-component, if set. Otherwise top relates to the browser's viewport. Setting top cancels bottom.
fromXvoidcheckedStarting point's X position measured in pixels. Modifies the default motion path, that components will be animated between.
fromYvoidcheckedStarting point's Y position measured in pixels. Modifies the default motion path, that components will be animated between.
motionPathsBiLine[]checkedThe array of motion paths consisting of BiLine objects.
speedvoidcheckedChanges the speed of the default motion path.
Time measured in milliseconds it should take to complete the animation of the default motion path. It Could also be a string with the following values:
slowest, slow, normal, fast, fastest
toBottomvoidcheckedSets the animation end y position relative to either a to-component, if set. Otherwise bottom relates to the browser's viewport. Setting bottom cancels top.
toComponentvoidcheckedInstead of using absolute window positions, you can position the animation relative another components position. By setting the to-component you specify another BiComponent whos location will be used for the animation's target state. If the to-component's location or size is changed, the animation will update dynamically. By default the top left corner of the to-component will be this animation's end x/y.
toLeftvoidcheckedSets the animation end x position relative to either a to-component, if set. Otherwise left relates to the browser's viewport. Setting left cancels right.
toRightvoidcheckedSets the animation end x position relative to either a to-component, if set. Otherwise right relates to the browser's viewport. Setting right cancels left.
toTopvoidcheckedSets the animation end y position relative to either a to-component, if set. Otherwise top relates to the browser's viewport. Setting top cancels bottom.
toXvoidcheckedEnding point's X position measured in pixels. Modifies the default motion path, that components will be animated between.
toYvoidcheckedEnding point's Y position measured in pixels. Modifies the default motion path, that components will be animated between.
typevoidcheckedSets both the speed and the acceleration type for the animation. Can be either:
"normal" or "smooth"

Methods

NameDescription
disposeCall this when you no longer need the object.
popPathPops the last added motion path, from the stack.
pushPathCreates a motion path, between two points and adds it to a stack.
setFromToSets the default motion path, that components will be animated between.

Events

None.

Static Methods

NameDescription
createConstantSpeedAnimates a component across the screen at a constant speed. Autostarts animation and autodisposes it.
createSlideSlides a component across the screen from one point to another. Autostarts animation and autodisposes it.

Static Fields

NameTypeDescripton
SPEED1NumberPredefined speed - slowest
SPEED2NumberPredefined speed - slow
SPEED3NumberPredefined speed - normal
SPEED4NumberPredefined speed - fast
SPEED5NumberPredefined speed - fastest

Remarks

If you just want to animate an object once, you can use the static convenience functions. If you use the speed constants, animation will synchronize with other animators. So if you for eg. set both a BiSizeAnimator and BiLocationAnimator to slow, they will finish their animation loops at the same time. You can also set the speed to the same milliseconds to achieve the same effect. If you don't supply oComp in the constructor, you should do so at a later point or there will be nothing to animate.

Method Details

dispose

Call this when you no longer need the object.

Syntax

object.dispose ( )

Parameters

No arguments.

Return Type

void

popPath

Pops the last added motion path, from the stack.

Syntax

object.popPath ( )

Parameters

No arguments.

Return Type

void

pushPath

Creates a motion path, between two points and adds it to a stack.

Syntax

object.pushPath ( [ x1 [ ,y1 [ ,x2 [ ,y2 [ ,nSpeed [ ,nAccType ] ] ] ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
x1Numberchecked0 Horizontal screen start position
y1Numberchecked0 Vertical screen start position
x2Numberchecked0 Horizontal screen end position
y2Numberchecked0 Vertical screen end position
nSpeedNumberchecked500 Duration of animation, measured in milliseconds
nAccTypeNumbercheckedBiComponentAnimation.CONSTANT_SPEED Acceleration type/behavior

Return Type

void

setFromTo

Sets the default motion path, that components will be animated between.

Syntax

object.setFromTo ( x1,y1,x2,y2 )

Parameters

NameTypeOptionalDefaultDescripton
x1NumberStarting point's X position measured in pixels.
y1NumberStarting point's Y position measured in pixels.
x2NumberEnding point's X position measured in pixels.
y2NumberEnding point's Y position measured in pixels.

Return Type

void

Static Method Details

createConstantSpeed

Animates a component across the screen at a constant speed. Autostarts animation and autodisposes it.

Syntax

BiLocationAnimator . createConstantSpeed ( x1,y1,x2,y2,oComp [ ,nSpeed ] )

Parameters

NameTypeOptionalDefaultDescripton
x1Numberfrom x
y1Numberfrom y
x2Numberto x
y2Numberto y
oCompNumberThe BiComponent to be animated
nSpeedNumbercheckedBiLocationAnimator.SPEED3 Select one of the predfined constants or supply your own value.

Return Type

void

createSlide

Slides a component across the screen from one point to another. Autostarts animation and autodisposes it.

Syntax

BiLocationAnimator . createSlide ( x1,y1,x2,y2,oComp [ ,nSpeed ] )

Parameters

NameTypeOptionalDefaultDescripton
x1Numberfrom x
y1Numberfrom y
x2Numberto x
y2Numberto y
oCompNumberThe BiComponent to be animated
nSpeedNumbercheckedBiLocationAnimator.SPEED3 Select one of the predfined constants or supply your own value.

Return Type

void