PDA

View Full Version : enabling back buttons in Flash


tooskinnee
06-26-2006, 03:52 PM
I have been using http://actionscript.org/tutorials/intermediate/Enabling_a_back_button_within_flash/index.shtml which uses Robert Penner script to enable the back buttons in flash. It works great and I am really impressed.

My question is, does anyone know how to use this to deal with movie clips that are not located on the _root timeline. If I have a MC that is nested inside of other MC's, I would still like to be able to make the back button work for these pages as well. Here is the code he uses:

// this code and back button by Robert Penner you can
// find it in full here http://www.robertpenner.com/
function checkPage () {
newPage = _root.page;
// grab variable from main timeline
// if the page variable has changed, navigate to new page
if (oldPage != newPage) {
// an object-oriented way of telling the
// content object to navigate to the new page
trace (newPage);
_root.gotoAndPlay("f"+newPage);
}
oldPage = newPage;
}




If any one has an idea or a tutorial that explians it let me know. THANKS!!!

tooskinnee
06-26-2006, 04:26 PM
I have been using http://actionscript.org/tutorials/intermediate/Enabling_a_back_button_within_flash/index.shtml which uses Robert Penner script to enable the back buttons in flash. It works great and I am really impressed.

My question is, does anyone know how to use this to deal with movie clips that are not located on the _root timeline. If I have a MC that is nested inside of other MC's, I would still like to be able to make the back button work for these pages as well. Here is the code he uses:

// this code and back button by Robert Penner you can
// find it in full here http://www.robertpenner.com/
function checkPage () {
newPage = _root.page;
// grab variable from main timeline
// if the page variable has changed, navigate to new page
if (oldPage != newPage) {
// an object-oriented way of telling the
// content object to navigate to the new page
trace (newPage);
_root.gotoAndPlay("f"+newPage);
}
oldPage = newPage;
}




If any one has an idea or a tutorial that explians it let me know. THANKS!!!

tooskinnee
06-26-2006, 10:46 PM
Sorry about the double post, I had to reload the page and...

Basically to make myself more clear, I want to use this code for my sub pages and since the navigation code in this tutorial only deals with the main timeline, I am not sure how to make it work for sub pages that are not on the main timeline. Any one have an answer or a tutorial to look trough?

jsebrech
06-27-2006, 07:22 AM
You could use two variables instead of one, page and subpage, and construct the URL from both of them. The trick here is that you need to change the URL of either the entire browser window or a frame in the browser window each time you want to add a history item. Then, when you navigate the history, it will change the URL's back to what they were at that point in the history. So, you need a way of coupling back the change to the state of your flash movie.

The way I did this was to always load a page into a hidden frame with embedded javascript that looked at the URL of its page, and sent a message to the parent (the containing html page in which the frame was embedded) to notify the flash movie that it should navigate. That works, but it's clunky.