PDA

View Full Version : _root.gotoAndPlay doesnt work in as3


makoinater
10-26-2008, 04:28 PM
prob simple but cant find answer - I have a function inside a movie clip where I want it to change to a frame on the main timeline.

_root.gotoAndPlay("framename"); doesnt work either does

gotoAndPlay("framename");

tried

stage.gotoAndPlay("framename");

also to no joy :(

jake2008
10-26-2008, 04:52 PM
Hey its my first time replying to these. So I hope this is of use.

What I would do is have your code on the main timeline.

Then to get to your button go

name_mc.button_btn.addEventListener(MouseEvent.CLI CK, goButton);

function goButton(e:MouseEvent): void {
gotoAndPlay("frame label");
}

this I think should solve your problem

makoinater
10-26-2008, 05:06 PM
Cheers for reply - while it would work I would like to keep it inside the movieclip as it is going to appear several times in the timeline and I would then have to rewrite the code each time as opposed to just the once.

well I'd assume I would - unless event listeners keep working even when you are not on the frame that they were initiated.

orange gold
10-30-2008, 12:27 AM
just make sure you added something like
_root.onEnterFrame = function() {
gotoAndPlay("frame name")
}

you cant just have it sit out there on its own it has to be inside a function

Ranoka
11-03-2008, 10:00 PM
In AS3 it's root not _root
Try this:

(root as MovieClip).gotoAndPlay("framename");

You need to cast the root as a MovieClip so that the player knows it can do frame stuff (since it could be a Sprite or different DisplayObject that might not).