Your UI will have some sort of button that the user used to get to the frame they are on at the moment. In very one of those scripts you would add the frame they are about to leave to an array, and if on the next screen they use a back button, you would go to the frame that was the last entry in the array.
var visited:Array = ;
var visitedpointer:int = 0;
// go to whereever that button would take the user, eg, frame 10:
visitedpointer = visited.length-1;
goforwardBtn.alpha = .5;
gobackBtn.alpha = 1;
I typed all that here, and didn't test it! You should get the general idea, and apply the approach to your code, rather than to copy and paste what I've shown.
There are complications to think about, like if the user goes back three times, then goes to a new destination, you might well clear out the visited list, otherwise there could be unexpected behavior if they go back again.
I answered the question you asked, then re-read what you wrote, and realized that you just want a pause menu that can be closed. The usual approach would not be to jump to the frame with the pause menu in it, but to have the pause menu be a hidden movieclip that sits on top of everywhere in the timeline. Then you only have to show or hide that movieclip, to reveal the screen that the user was on at the time.
Another approach is to have a movieclip in the library that you add using code, and when the user has finished pausing you would remove the movieclip with code.
hi, thank you so much for your detailed response, it was very helpful! your second suggestion seems a lot simpler, so i put all the pause menu objects into one movie clip and i have no trouble hiding it (using a button within the movie clip that hides 'this') but i can't seem to get it to show up again. i've named the movie clip instance as PAUSEMENU but when i try to get a button to do 'PAUSEMENU.play();' or 'PAUSEMENU.visible = true;' it doesn't work. do i need to somehow define the pause menu within the code before i refer to it? thank you again for your help (:
It's unusual to name symbols in all caps, so maybe you've got a letter wrong? Also, so far it hasn't mattered whether you were doing AS3 or HTML5 Canvas, but as far as talking to symbols on the stage it can be different. In AS3 you can talk to a symbol as you enter the first frame it exists. With Canvas it's not so easy. The simple solution to that is to have the symbol on a frame before where your script is.
So, use lowercase, like 'pausemenu', then there is less to get wrong when typing. pausemenu.visible = true should work.
thanks for your reply! hmm.. for some reason it still doesn't work, i get an error "#1009: Cannot access a property or method of a null object reference". i tried extending the movie clip to cover the whole timeline, because maybe it wasn't working because the movie clip wasn't present in the frame. but i then noticed that the close button only hides the button itself with the "this" command, and not the rest of the movie clip. i tried fiddling with that, but when i write pausemenu.visible instead of this.visible, it tells me i'm accessing an unidentified property. am i not allowed to refer to the movie clip within the movie clip itself..? (since the button is inside the movie clip) i've double-checked all the instance names and they seem to be fine..
If the button that shows the pause menu is at the same level as the pause menu movieclip, its click function would be like:
pausemenu.visible = true;
If the button that closes the pause menu is inside the pause menu movieclip, its click function would be:
e.currentTarget.parent.visible = false;
Or you could have the show and hide functions on the main timeline, like:
pausemenu.visible = true;
pausemenu.visible = false;
The show pause menu button function would be:
and the close button inside the pause menu would have:
excellent! i managed to get it to show up again! thank you so much! i've just got two more questions:
1. how can i get the animation inside the pause menu to play again when it becomes visible?
2. when i use the first code for the pause button inside the movie clip, it tells me "e" is unidentifiable. was that supposed to be something else? i tried movieclip(parent).visible = false; instead but then everything on the canvas disappears! if it continues not to work, i might just move the button outside the movie clip as that seems simpler.