Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button in mc wont direct to next scene

Status
Not open for further replies.

karenina

Technical User
Aug 5, 2006
3
PH
Hello,

I just discovered something weird.

I have made a movie with different scenes in it.
If I use a button, which is on the main stage, to go to the next scene everything works fine. If I use a button which is inside a mc the same actionscript doesn't seem to work anymore.
Here's the actionscript:
on(press)
{
gotoAndPlay("scene2", "start");
}


I've also tried

on(press)
{
_root.gotoAndPlay("scene2", "start");
}
but that doesn't seem to work either.
Can someone help me out?
karenina.
 
on(press) {
_root.yourmcname.gotoAndPlay("scene2","start");
}

make sure you name the instance of your movie clip in the instance panel..whatever you name it in the buttons actions..give it the same name in the instance panel..
logo.gif


carlsatterwhite@orlandomediasolutions.com
 
Once again!...
Movie clips or loaded movies on other levels see the timeline of the main movie as one big scene even if it holds dozens of them.
You're right in assuming you should be using _root, in the case of movie clips, but you should replace _root by _level0, when targeting the main timeline from a loaded movie on another level, because each .swf has it's own _root level.

Now for calling a particular scene of the main movie from within a movie clip, you either have to calculate the cumulative number of the frame targeted or better, use a frame label.
Thus, if you're targeting frame 10 of scene 2 and your scene one holds 100 frames, you would target (100+10)= 110 as:
on(press){
_root.gotoAndPlay(110);
}
The problem with that method, is that if you edit any scene (shorten them for example), you'll have to re-calculate every frame targeted in all your calls, so that they match the new cumulative number. It is thus much more easy and better to use an unique label and target that label.
If you labeled frame 10 of scene 2 in the above script as start,then the call would look something like this:

on(press){
_root.gotoAndPlay("start");
}

From a loaded movie on another level the same call would be:
on(press){
_level0.gotoAndPlay("start");
}

Regards,
wink4.gif
ldnewbie
 
Thanks for your reply, virt2001!

I've just tried it several times but I can't get it to work.

Here's what I did:

I've created a mc which has in the last frame a stop action and a button with this action:
on(press) {
_root.test.gotoAndPlay("scene2","start");
}

I drag the mc from the library on stage in the first scene and call it test in the instance panel and put a stop action in the same frame.

I then create scene 2 and label the first frame start.
I've put a stop action in scene 2 so it wont jump right away back to scene 1.

When I test the movie I get a handcursor when I roll over the button but clicking it doesn't have any effect.

Is there something I forgot to do?
Thanks, karenina
 
Thanks oldnewbie,
your solution does the trick.

best wishes, karenina
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top