Moscrif API Docs for: 2012q3
Show:

Animator Class

include "lib://core/animation/animator.ms";
Library: core

Constructs animator objects

Example:

// create animator
var animator = new Animator({
    interval: 1,  // time between animation frames
    duration: 400, // length of animation
    onComplete: function(){},
    onStep: function(){},
    transition: Animator.Transition.easeInOut
});
animator.addSubject(function(state) {            // state starts from 1.0 to 0.0
    var self = this super;
    self.alpha = (state*255).toInteger();
})
// play animator
animator.play();

Constructor

Animator

(
  • [options]
)

Parameters:

  • [options] Object optional

    {Object} Options to construct animator object. The default options are:

Example:

// create animator
var animator = new Animator({
    interval: 1,  // time between animation frames
    duration: 400, // length of animation
    onComplete: function(){},
    onStep: function(){},
    transition: Animator.Transition.easeInOut
});
animator.addSubject(function(state) {            // state starts from 1.0 to 0.0
    var self = this super;
    self.alpha = (state*255).toInteger();
})
// play animator
animator.play();

Methods

applyDefaults

(
  • defaults
  • prefs
)
static

Merge the properties of two objects

Parameters:

  • defaults Object

    Configuration object with animator defaults

  • prefs Object

    Custom configuration object

clearSubjects

()

Remove all subjects

jumpTo

(
  • to
  • [propagate=true]
)

Animate from the current state to provided value

Parameters:

  • to Float

    Defines start point

  • [propagate=true] Boolean optional

    If true, the current state of to the animation subjects will be forwarded. False it jump to the target only.

makeADSR

() Function static

Make an Attack Decay Sustain Release envelope that starts and finishes on the same level

Returns:

makeBounce

(
  • bounces
)
static

Make a transition function that, like a ball falling to floor, reaches the target and bounces back again

Parameters:

makeEaseIn

(
  • a
)
Function static

Make a transition function that gradually accelerates. pass a=1 for smooth gravitational acceleration, higher values for an exaggerated effect.

Parameters:

Returns:

makeEaseOut

(
  • a
)
Function static

As makeEaseIn but for deceleration

Parameters:

Returns:

makeElastic

(
  • bounces
)
static

Make a transition function that, like an object with momentum being attracted to a point, goes past the target then returns

Parameters:

onTimerEvent

()

Called once per frame to update the current state

play

()

Play animation

reverse

()

Reverse animation

seekFromTo

(
  • from
  • to
)

Animate from the current state to provided value

Parameters:

  • from Float

    Defines start point

  • to Float

    Defines end point

seekTo

(
  • to
)

Animate from the current state to provided value

Parameters:

  • to Float

    Defines end point

setOptions

(
  • options
)

Apply default options

Parameters:

  • options Object

    Configuration object ot be applied to the Animator default options

stop

()

Stop animation

toggle

()

Seek to the opposite of the current target

Properties

duration

Integer

Length of animation in miliseconds

interval

Integer

Time between animation frames in miliseconds

transition

Transition

Transition

Events

onComplete

Call-back function. This function is called when application ends.

onStep

Call-back function. This function is called when animation frame is changed.