I have a 100-frame movie clip, a_mc, on the stage.
I want it automatically gotoAndStop at a certain frame, labeled as “about”, on the stage (root level).
How should I do?
(AS3 version please…)
I know how to do this from a root to control a movie clip only.
That would go to the “about” label in the a_mc timeline. To go to “about” in the root (main) timeline, you would need to call gotoAndStop from root.
if you’ve written your code in the main timeline, this could be as simple as gotoAndStop(“about”);, but if you’re calling from another location (i.e. within the a_mc timeline) then you’ll need to specify root directly.
root.gotoAndStop("about");
However, this will only work if the timeline you’ve written that script in is visible and on the active display list. It might not work if you created an instance of that movie clip dynamically with ActionScript (since you need to be on the display list for the root property to correctly reference the root timeline, otherwise its null).
[quote=senocular;2352466]That would go to the “about” label in the a_mc timeline. To go to “about” in the root (main) timeline, you would need to call gotoAndStop from root.
if you’ve written your code in the main timeline, this could be as simple as gotoAndStop(“about”);, but if you’re calling from another location (i.e. within the a_mc timeline) then you’ll need to specify root directly.
However, this will only work if the timeline you’ve written that script in is visible and on the active display list. It might not work if you created an instance of that movie clip dynamically with ActionScript (since you need to be on the display list for the root property to correctly reference the root timeline, otherwise its null).[/quote]
Thank you so much for reply.
I want it jupms to the “about” label in the main timeline after a_mc plays to the end. (There is no a_mc at “about” label key frame.)
I inserted a keyframe at the end of my a_mc and added this code:
root.[COLOR=#0000ff]gotoAndStop[/COLOR]COLOR=#000000[/COLOR];
However, there was an error: 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display: DisplayObject.
It automatically go to the “about” label in the main timeline even a_mc is not playing to the end. I guess maybe because Flash calls the action to root at the first priority no matter where this code is?? I wish I could better explain…