Graphics Reference
In-Depth Information
And of course, all Timeline functions are available: ( stop() , stop(value),
play(), play(value) , and playReverse() ). More information on navi-
gating through the symbols within a composition is presented in sections 5.5.4
and 5.5.5.
To control the Timeline, you often need additional information, such as the to-
tal duration of the animation and playhead state. The Edge Animate API provides
a few useful functions. For example, to determine the current position of the
playhead in a symbol instance, use the following function. The function returns
the value in milliseconds.
// Determine current position
var myPos = sym.getPosition();
This value is often used in relation to the total time, which you can get in the
following way:
// Determine total duration of a Timeline
var myDur = sym.getDuration();
In some cases, actions vary depending on the state of a Timeline. If you want
to determine whether a Timeline is playing, you can use the isPlaying()
function.
// Check state of a Timeline
var myState = sym.isPlaying();
This function returns a Boolean value, either true or false. This value can then
be further processed, for example, within an if statement:
if ( sym.getSymbol("intro").isPlaying() ) {
console.log("Intro is still playing...");
}
else {
console.log("Intro is done...");
}
Together with sym.playReverse() , you can additionally examine whether
the Timeline is currently playing backwards. The function isPlaying() returns
true again.
// Check if a Timeline is played backwards
var myStage = sym.isPlayDirectionReverse();
 
Search WWH ::




Custom Search