Flash CS3 Root Timeline Control Within Movie Clips
So I decided I would use the blog to talk about some things I’ve learned about Flash CS3. It’s been a lot of fun learning Actionscript 3 but there are some things that aren’t so intuitive or obvious. One of those things I struggled with tonight was controlling the root timeline from within a Movie Clip. It’s actually very simple once I found the solution.
MovieClip(root).gotoAndPlay(10);
That will move the playhead to frame 10 and play onward. Simple right? You can attach any timeline control you want.
MovieClip(root).gotoAndStop(10);
That will go to frame 10 and stop.
I looked for this solution for 30 minutes and smacked my head when I found it. Googling the right words is key.
17 Comments to “Flash CS3 Root Timeline Control Within Movie Clips”
Leave a Reply

Check out “Learning ActionScript 3.0″ from O’Reilly. Awesome book for learning AS3. Full color, great examples, great intro into OOP without requiring that you know all about it, etc. It changed my (work) life.
Michael: Actually, I just picked up that book a week ago. So far so good! Have any other good resources for Actionscript?
Hi narkeeso,
I found your post online and I have a related problem, so I figured I’d ask you about it, in case you have the time and inclination…
I am trying to send the main timeline to a specific frame from an animated button.
I have an animated button that does some graphic stuff (that is actually right out of a tutorial from this site) and then, at the end, I have a frame with your code to send the action to frame 10 in the main timeline.
MovieClip(root).gotoAndPlay(10);
It works ok, except for 2 things:
1- It throws this error right at the beginning (even before hovering):
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::Symbol3_2/frame16()
2- Then it throws the same error again when i am no longer hovering over the button.
I hope you can help! Thanks in advance
Raul
“I have an animated button that does some graphic stuff (that is actually right out of a tutorial from this site)”
Sorry, I got confused. The tutorial is actually NOT from here.
Thanks Narkeeso,
It’s worked,
Thanks
You are awesome, just used this now and it works great
This was a great find for me seeing as it only took me 15 minutes thanks to your initial 30…lol however I had to add an “_” before ‘root’ (_root) to get it to work.
Thanks for this. I’ve spent ages trying to get this kind of code to work:
root.mymovie_mc.rotation = 45;
parent.mymovie_mc.rotation = 45;
However:
this.othermovie_mc.scaleX=.5;
Using ‘this’ seems to work.
Any ideas why the root.moviename. target path doesn’t seem to work in AS3; even though the ‘insert target path’ button gives these paths (and it is the suggested method in my CS3 book.
Cheers again
R
3hrs looking for this ‘simple’ solution. Annoyed as I’ve already seen it, I assumed MovieClip was an instance name doh!
Thank you very very much
/nuro
I’m trying to get this code to work on mouseclick, but things just are not cooperating for me. I’m using the following:
next_mc.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(event:MouseEvent):void {
MovieClip(root).gotoAndPlay(“ExteriorBack”);
}
Laura
Great post! Really helpful! You’ve shortened my searching. Keep up the good work
.
MovieClip(root).gotoAndStop(10); you’re a genius. Thanks for posting this.
on (press) {
_root.gotoAndStop(40);}
vato vato vato!! its a mexican term for excitement! you save my little ass! thank you you are awesome!
greetings from monterrey mexico
I dont know what to do pls help me.
Here’s my problem:
In my main timeline, i have my “FLAGS” with the names (LOCATION, MENU and HOME) in different frames. i have a main bar on the bottom that has all my menu buttons, that bar has an instance(menu2) its a movie clip that inside has my buttons. I can’t make those buttons control my main timeline, i get errors.
The reason i have the actions for this buttons in my main timeline, its because when i go to the frame with the flag LOCATION, i dont want this same link to be active, it looks bad.
heres the code im using:
function goLocation(event:MouseEvent):void {
MovieClip(root).gotoAndStop”LOCATION”);
}
menu2.locationBtn.addEventListener(MouseEvent.CLICK, goLocation);
and this is the website im building http://www.azuldowntown.com
thank you very much for your time.
Best regards.
OK i found the problem, its wasnt the script, it was that my buttons didnt start at the first frame, so i guess thats why the script didnt find them. Now, can someone help me with the part that i dont know how to disable the function on the same FLAG, for example:
If im in Home and i click to go to Location, i want Location to be disable once i get to that frame where Location is, in other words, i dont want to press the button and reload the same frame im at, since im going to use animation for the entrace and exit for each section.
Thanks!
Hey, that is awesome! You were right, simple. So simple, in fact, I was skeptical if it would work. But it solved my problem like magic! Thanks for the easy fix!