Skip to main content
Known Participant
August 2, 2022
Answered

How can I control the root timeline from within a movie clip with HTML5?

  • August 2, 2022
  • 2 replies
  • 514 views

Can anybody guide me on how to control the main root timeline from within a movieclip with HMTL5?  I remember doing this years ago with actionscript and I think all I needed to do was add ".root" somewhere and it worked but I'm not sure how to go about it now with HMTL5.

 

Here's my specific scenario.  I have a movieclip on my root timeline.  That movieclip has a bunch of frames inside of it that you can flip through by clicking a next button which is also inside that movieclip.  When you get to the final frame of the movieclip I want that next button to now take the use to a different point of the main root timeline.

 

I imagine the code would not be that different from basic timeline navigation but with some addition to specify which timeline I'm referring to but I dunno.

 

What do you guys think?

Thanks in advance.

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

Animate automatically creates a global variable that refers to the root Movie Clip (main timeline) called exportRoot.

 

So, for example, you can write...

 

exportRoot.gotoAndStop(1);

 

 

... to send the root Movie Clip to the second frame.

 

I hope it helps.

 

Regards,

JC

2 replies

JoãoCésar17023019
Community Expert
Community Expert
August 2, 2022

Or you can also store a reference yourself in the main timeline like this:

window.root = this;

 

Or just:

root = this;

 

In this way, you are creating a property in the window object that stores a reference to the root Movie Clip (main timeline) called root, that you can access from anywhere in the same window.

 

Regards,

JC

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
August 2, 2022

Hi.

 

Animate automatically creates a global variable that refers to the root Movie Clip (main timeline) called exportRoot.

 

So, for example, you can write...

 

exportRoot.gotoAndStop(1);

 

 

... to send the root Movie Clip to the second frame.

 

I hope it helps.

 

Regards,

JC

Known Participant
August 11, 2022

Oh great!  I bet that will work!  I'll give it a try.  Sorry or the slow response, I never got any notifications of the replies so I didnt' think I'd gotten any answers at first./

Thanks!!!

JoãoCésar17023019
Community Expert
Community Expert
August 11, 2022

No worries and you're welcome!