Skip to main content
Participant
December 2, 2016
Answered

External Playing/Stoping the Canvas

  • December 2, 2016
  • 2 replies
  • 1569 views

Hi there !

I have an HTML project that loads HTML's generated through Animate.

I need a way, from my "container" page, to stop and play the "main timeline" of the Animate generated page. It would be just as if I called the "this.stop()" or "this.play()", but from my container, through Javascript.

I tried a loooot of the "easy" things, including passing as a parameter a function that would call the "this.stop()" from inside the Animate code.

The Animate code easily calls functions from my external Javascript, but I couldn't, for the life of me, call the Animate functions from my JS.

Thanks all ! 

    This topic has been closed for replies.
    Correct answer ClayUUID

    This has been asked a few times. There's literally no difference between JavaScript coded inside Animate and JavaScript anywhere else in the same HTML document, so all you need is the right object reference. Conveniently, Animate defines a global reference to the root timeline, exportRoot. You can prove its validity by dropping this code in your root timeline:

    alert(exportRoot === this);

    If you get "true"—which you should—then you're golden. So all you have to do to control the main timeline is:

    exportRoot.stop();

    exportRoot.play();

    2 replies

    ClayUUIDCorrect answer
    Legend
    December 2, 2016

    This has been asked a few times. There's literally no difference between JavaScript coded inside Animate and JavaScript anywhere else in the same HTML document, so all you need is the right object reference. Conveniently, Animate defines a global reference to the root timeline, exportRoot. You can prove its validity by dropping this code in your root timeline:

    alert(exportRoot === this);

    If you get "true"—which you should—then you're golden. So all you have to do to control the main timeline is:

    exportRoot.stop();

    exportRoot.play();

    kglad
    Community Expert
    Community Expert
    December 2, 2016

    open your .js file in a text editor and edit it to do what you want.