Skip to main content
alexandermouton
Participant
April 21, 2017
Answered

how to control main timeline from within a movie clip using javaScript?

  • April 21, 2017
  • 3 replies
  • 2902 views

Hello,

As background, I am an old AS3 coder and I have not touched code for a few years as I have been waiting for developers to integrate javaScript into Flash.  I do not know javaScript, however I am trying to get up and running with Animate CC using javaScript and HTML5.  My problem is that I want to target the main timeline from within a movie clip and I do not know the syntax to refer to it.  In AS3, the main timeline could be referred to as "root".  This way, if I wanted to control the timeline of an MC from within it, I could say this.gotoAndPlay and if I wanted to control the main timeline from within that MC, I could write root.gotoAndPlay.  I have no problem writing frame actions on either timeline, but how do I have an action on the timeline within an MC refer to the main timeline?

What I am trying to do seems so simple, yet I'm stumped even after searching the interwebs.  I would like to have a movie clip sit on frame one of the main timeline with a stop action on that frame.  When the movieclip's timeline runs its course, i would it to stop and tell the main timeline to move forward to frame two.

How do I refer to the main timeline using javaScript?  Is there an equivalent to root?

This topic has been closed for replies.
Correct answer ClayUUID

exportRoot

3 replies

alexandermouton
Participant
April 24, 2017

Thanks for these responses! 

I was successfully able to access the main Animate CC timeline from within an MC using either of these lines of code:

exportRoot.gotoAndPlay();

this.parent.gotoAndPlay();

I see that CreateJS lists all the methods, properties, and events for the Movie Clip Class, however not how to actually employ the code. Can you recommend a resource where I can learn more about incorporating javaScript in Animate CC?

Thanks!

Preran
Legend
April 21, 2017

In addition to what clayUUID said, see this discussion What is root when converting AS3.0 to Create js? where this topic has been discussed.

ClayUUIDCorrect answer
Legend
April 21, 2017

exportRoot