How To Access the Main Timeline in Flash Actionscript 3

I recently had to port a project that I am working on to Actionscript 3 from Actionscript 2. It was a pretty smooth transition until I came to a point where I needed to access the main timeline within a dynamically placed movieclip. I was tearing my hair out trying to figure out how to freaking access the main timeline!

Long story short
In Actionscript 2 it would be:

root.gotoAndStop(5);

To do this in Actionscript 3:

MovieClip(this.root).gotoAndStop(5);

I'm not exactly sure why this works the way it does, but it does. I had to get the Yoda of Actionscript to help me out with it. Here is a simple FLA (Flash version CS3) example. Access Main Timeline Example

Leave me a comment if you've found this helpful, Good luck!

Anonymous's picture

you're brilliant. i love you!

you're brilliant. i love you! thank you very much, i've been struggling for 3 days to figure out that one

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <b> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <br> <blockquote> <align> <p> <h1> <h2> <h3> <h4> <object> <param> <embed>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Twitter-style @usersnames are linked to their Twitter account pages.