Skip to main content
Participant
April 27, 2017
Answered

Timeline complete event

  • April 27, 2017
  • 2 replies
  • 2313 views

Hi,

Within the HTML file generated by publishing a HTML5 Canvas animation, how can I create a function that's triggered when the main timeline animation is complete? I've found Adobe Edge references like that below:

AdobeEdge.Symbol.bindTimelineAction(compId, "stage", "Default Timeline", "complete", function(sym, e) { console.log('timeline complete'); });

But how do I perform such actions within the HTML file generated by Adobe Animate CC 2017?

    This topic has been closed for replies.
    Correct answer kglad

    the easiest way is to place a function call on the last frame of the main timeline.

    another way would be to use a tick loop to repeatedly compare the currentFrame and totalFrames.

    2 replies

    Participant
    April 28, 2017

    Thanks all, for my purposes the main timelines change event appears suitable.

    mainTimeline = stage.children[0].timeline;

    mainTimeline.addEventListener("change", onAnimatingMainTimeline);

    function onAnimatingMainTimeline () {

         if (mainTimeline.position == mainTimeline.duration) {

              console.log("animation complete");

         }

    }

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    April 27, 2017

    the easiest way is to place a function call on the last frame of the main timeline.

    another way would be to use a tick loop to repeatedly compare the currentFrame and totalFrames.

    Legend
    April 27, 2017

    Curiously, the only event the Timeline class supports is "change". You'd think there would be a "complete" and/or "loop" event. Maybe if enough people asked for it they'd add it. Wouldn't take much effort.

    kglad
    Community Expert
    Community Expert
    April 27, 2017

    i don't think the change event works the way someone coming from a flash/animate background would think.  i believe it's triggered when the timeline is shortened or lengthened, not when the timeline changes from one frame to another.