Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Timeline durations in Flash/Animate aren't mutable at runtime, so that wouldn't even make sense.
TweenJS v0.6.2 API Documentation : Timeline
Copy link to clipboard
Copied
you're correct.
Copy link to clipboard
Copied
There's nothing like the detailed Edge Animate API anymore?
Copy link to clipboard
Copied
Of course there still is... in Edge Animate.
Animate CC in Canvas mode uses the CreateJS API.
CreateJS | A suite of JavaScript libraries and tools designed for working with HTML5
Copy link to clipboard
Copied
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");
}
}