Back button that takes you to the last Scene visited

Hello Kirupa forum,

First off, i just want to say that I’m pretty much a newbie when it comes to Flash MX ActionScript.

Okay, here here’s my situation…

I just created a Flash MX document with 10 scenes.

I have included a menu that will take the user to any of the 10 scenes. Moreover, in each of these 10 scenes, I added a BACK, NEXT, and HOME button for navigation purposes.

My problem is this…

I was at ‘Scene 1’ and I wanted to jump to ‘Scene 7’, so I go to my menu and clicked on the button that would take me to ‘Scene 7’.

Okay…now that I’m at ‘Scene 7’ I want to go back to ‘Scene 1’. BUT THIS TIME I WANT TO USE MY NAVIGATION BUTTONS.

So I press the BACK button from ‘Scene 7’ and it takes me to ‘Scene 6’. (I already know why it took me to ‘Scene 6’ instead of ‘Scene 1’.) BUT, I WANTED IT TO GO BACK TO THE LAST SCENE VISITED!

So my question is this…

How do you get FLASH MX to remember which Scene you last visited?

Is there a script that I must add to force it to remember the last scene visited?

thank you Kirupaforum,
cobaltblue

I believe that it can be done by setting up a var.

in scene 1 set up vars

back = HOME
next = SCENE2
home = HOME

and a var for each of your 10 scenes.

when you click on a button next you change the vars.

So in your example…
you click on the scene 7 button and change the vars to…

back = HOME
next = SCENE8
home = HOME

hence now when you click the back button you will be taken back to home, instead of scene 6…

hope this helps

I have a slightly different answer.

Set up a variable on your main timeline… something like:

[AS]var lastplayed=“one”[/AS]

Then, your buttons could be setup this way…

[AS]
mybutton1.onRelease=function(){
_root.lastplayed=“one”;
//put the rest of your code here
}

mybutton2.onRelease=function(){
_root.lastplayed=“two”;
//put the rest of your code here
}
[/AS]

Then, you could simply set up your back button to say something like:

[AS]
backbutton.onRelease=function(){
gotoandplay(_root.lastplayed);
}
[/AS]

btw, all the code I have included would be placed in a single frame on the MAIN TIMELINE, not on the objects (buttons) themselves.

I hope this at least provides you with some of the logic behind coding something like that.

you have to love functions…

functions are your friends.

yes, functions are you friends, but they i would do this would be without any functions at all.

i love to use _global.variables in my works. So much easier to contact. SOOOO … a script ON a button would be like yours, Inigo, Whatever button you click, the Global variable:

_global.lastPlace

gets set to that, and the “lastPlace” would be where your back button would take you.