NodeFire Library

anim  1.0.6

NodeFire Library > anim > NF.anim.player
Search:
 
Filters

Class NF.anim.player

Includes methods for playing a timeline. A timeline may include multiple tracks, each with multiple clips. When playing the timeline, the clip animations in each track for the current frame are simultaneously rendedered.

It is not necessary to directly create a player object when applying animations to widgets with hooks. The NF.anim.transition class in coordination with the widget and playerSynchronizer will handle the rendering automatically.

The player can be used to directly play clips attached to widget Nodes, however it is primarily ment to play clips attached to document Nodes outside the widgets.

Constructor

NF.anim.player ( playObject , frameDelay , loop )
Parameters:
playObject <object> [timeline | clip | clip Array] A timeline (NF.anim.timeline), clip (NF.anim.clip), or Array of clips. Clips are automatically converted to timelines. Arrays of clips are converted to a timeline with a single track containing all the clips which are played sequentially.
frameDelay <int> Optional - The time (in milliseconds) to delay between frames. Default: 15.
loop <string | int> Optional - The number of times to loop the timeline when playing. Pass an int or "infinite".

Methods

changePlayDirection

void changePlayDirection ( )
Change the current play direction between 'forward' and 'reverse'. The direction may be changed during or before playing.
Returns: void

getHook

string getHook ( )
Get the hook attached to the timeline object for this player.
Returns: string
The timelines optional hook setting.

getPlayDirection

string getPlayDirection ( )
Get the current play direction.
Returns: string
The play direction..."forward" or "reverse".

getTimeline

Object getTimeline ( )
Get the timeline associated with the player.
Returns: Object
timeline The players timeline object.

isPlaying

string isPlaying ( )
Determines if the players timeline is currently playing. Paused, stopped, and stepped timelines return a negative playing status.
Returns: string
The direction of play "forward" or "reverse", if playing.

pause

boolean pause ( )
Pause the player. This is a toggle method, subsequent calls will unpause and pause. Player actions such as step may be applied while paused.
Returns: boolean
True if paused.

play

void play ( )
Plays the timeline.
Returns: void

setPlayDirection

boolean setPlayDirection ( direction )
Sets the play direction forward or reverse. The direction may be changed during or before playing.

Note: If set to "reverse" before playing, clips with styleAnim refNodes set to "self" may not animate as intended. This is due to the fact that as the player runs through clips that use "self" as the refNode, the previous dimensions or locations from clip to clip within a track may be diffierent depending on the play direction. This is not an issue when reversing during play, as the dimensions and locations have been calculated to the point of reversal.

You can overcome this potential issue by using fixed locations and dimensions, or locations and dimensions relative to a static Node such as the parent container. By default syleAnim property settings are relative to the parent container.
Parameters:
direction <string> Set to "forward" or "reverse".
Returns: boolean
directionChanged True if the direction was changed.

step

boolean step ( frames )
Steps the player position a set number of frames. The player must be stopped or paused before stepping.
Parameters:
frames <int> The number of frames to step in the timeline.
Returns: boolean
True if the player reached the beginning, or end of the timeline.

stop

void stop ( )
Stops the player and sets the timeline frame position to the beginning.
Returns: void

Events

paused

paused ( event )
Fires on a player object when the timeLine is paused on a frame.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.
  • {framePos:int} The frame position which the player paused on.

playedToEnd

playedToEnd ( event )
Fires on a player object when the timeLine is played to the end.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.

playedToStart

playedToStart ( event )
Fires on a player object when the timeLine is played to the start. This can occur when reversing the play direction.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.

playResume

playResume ( event )
Fires on a player object when the timeLine is played for the first time, starts a new loop, or play is resumed from pause.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.
  • {framePos:int} The frame position which play started from.

stepped

stepped ( event )
Fires on a player object when the timeLine is moved by a step.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.
  • {framePos:int} The frame position stepped to.

stopped

stopped ( event )
Fires on a player object when the timeLine is stopped.
Parameters:
event <object> Object literal containing the following properties...
  • {type:string} The type of event.
  • {target:object} The player object which dispatched the event.
  • {framePos:int} The frame position stopped on.


Copyright © 2011 OpenCube: Inc. All rights reserved.