Changing scene from within a movie

10 posts

Flag Post

Ok, I’ve been struggling with this for an hour and my brain isn’t working today. Can one of you flash guru’s help me out?

I used to have a button with the code: gotoAndStop(“scene2”, 20);

Now that button is within another movie and pressing it won’t change the scene anymore. I’ve tried: _root.gotoAndStop(“scene2”, 20); but that doesn’t work. What’s the proper way to do this?

Thanks again,

-Sage

 
Flag Post

Got it!

movie.button.onRelease = function() { gotoAndStop(“scene2”,20)} in my actions section.

Thanks, posted too soon! =)

 
Flag Post

I’ve had a similar problem before now.

My solution was to create a function on the main timeline something like this:

function nextScene() {
gotoAndStop(“scene2”, 20);
}

Then the button code was:

on(release) {
_root.nextScene();
}

You could pass the frame and scene name as parameters to this function and make it more useful, like this:

function gotoScene(theScene:String, theFrame:Number) {
gotoAndStop(theScene, theFrame);
}

Personally I think this solution is a little better.

 
Flag Post

The reason for the issue is that code to change scene can only exist on the main timeline. You can’t get around this by using “with(_root) { }” either.

 
Flag Post

You can just use a frame label in that scene and go to that frame just as you normally would using a label. Treat it like any other timeline, and forget that it has different scenes. You want to avoid using frame numbers in many cases anyway, bad practice.

 
Flag Post

So arcane, you can still use frame labels and yet direct them to the specified frame even in different scenes? Because my game needs scenes badly :(

 
Flag Post

Yes, Flash compiles it down to one timeline. The scenes are just a means of visual organization for you. Treat it just like you would any other MovieClip timeline.

 
Flag Post

That’s handy to know – I’ll use that in future.

BTW Arcane, you are nearly on 1337 posts!

 
Flag Post

BTW Arcane, you are nearly on 1337 posts!

He just needs 1 post to be 1337. Boy, is he spamming like crazy :P

Thanks, arcane. This is gonna be handy to know a nifty trick like this :D

 
Flag Post

I hate scenes. Never use em. XD