Addressing to a specific scene

Hi,

I’m in a movieclip wich contains different buttons.

this movieclip is on the root but I can’t tell those buttons to go to and stop “scenexyz” of the root

I tried with:

on (release) {
_root.gotoAndStop(“scenexyz”, 1);
}

but it didn’t work…
what’s the right syntax?

Just go to the first frame of whatever scene you want to link to and create a layer called, “Actions”. Select the first frame of this layer (in the scene you want linked), open the properties inspector and replace “<Frame Label>” with whatever you want to be used as an ID for this frame.

Then just add the code:

//you have a frame in the next
// scene named "scene2"
myButton.onRelease = function() {
     _root.gotoAndPlay("scene2");
}

When Flash compiles your SWFs, it just creates on enormous timeline comprised of all the scenes.

Let’s say you have two scenes, the first one is 200 frames long and the second one is 300 frames long. The second scene isn’t actually going to be a whole new movie or anything remotely separate, it’s going to start at frame 201, right after the end of the first “scene”.

Knowing this, naming your frames as outlined above and controlling the playhead should be a bit easier to understand. That’s why there is no native way to reference scenes from a gotoAndPlay anymore – it’s all one long timeline. Scenes are simply there to help aid the designer by keeping things compartmentalized and compact – that’s it.

But keep in mind that since it is all (once compiled) one big-*** timeline each frame label needs to be unique to the level it’s on. You can’t have two "myScene"s on _root, but you could have on “myScene” on _root and another within a movieclip like myMovie | myScene:

// one scene on _root named "myScene"
// another scene within the navMC
// named "myScene"
button1.onRelease = function() {
     _root.gotoAndPlay("myScene");
}
button2.onRelease = function() {
     _root.navMC.gotoAndPlay("myScene");
}

I would recommend keeping all frame labels unique though, it’s just easier that way…:wink: