|
-
Twansparant
Swfaddress Back & Forward problem
Hi there,
I'm trying out swfaddress (v 2.4) for the first time in my XML driven website and I almost got it working properly accept for the Back & Forward handling.
My menu is build up from XML nodes, when pressing one of the menu buttons, a variable is set, the appropiate function gets called and swfaddress changes the URL address and page title correctly.
When I go directly to one of the deeplinks in my browser, the variable is not set yet so I construct the variable and it's function from the swfaddress deeplink and the correct page gets loaded. So far so good!
However if I press Back or Forward in my browser only the URL address changes correctly but the page title stays the same and the function doesn't get called. Somehow the Back & Forward button don't fire the SWFAddress.onChange function...
I'm so close! Could someone how a look to see what I'm missing in my AS?
I don't see it anymore... Any help is appreciated! My AS:
Actionscript Code:
// SWFAddress include #include "com/swfaddress/SWFAddress.as"
// Load XML var myXML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(success) { if (success) { makehoofdmenu(); SWFAddress.onChange(); } else { trace("The XML could not be loaded"); } }; // Prevent XML caching myXML.load("content.xml?cachebuster=" + new Date().getTime());
// Menu var tmpWidth = 25; var spacing = 20; var Status:Number = 0;
var hoofdmenuitems:Array; var hoofdmenutotal; var page:Number = NaN; var pages:Array; var tmpl:Array; var button:Array; var activeNo:Number = NaN;
function makehoofdmenu() { hoofdmenuitems = myXML.firstChild.childNodes[1].childNodes; hoofdmenutotal = hoofdmenuitems.length; pages = []; tmpl = []; button = []; for (s=0; s<hoofdmenutotal; s++) { pages[s] = hoofdmenuitems[s].attributes.title; tmpl[s] = hoofdmenuitems[s].attributes.template; button[s] = hoofdmenu.items.createEmptyMovieClip(s, hoofdmenu.items.getNextHighestDepth()); button[s].createTextField("title", 1, 0, 0, 1, 15); button[s].title.setNewTextFormat(Avenir); button[s].title.embedFonts = true; button[s].title.autoSize = true; button[s].title.html = true; button[s].title.antiAliasType = "advanced"; button[s].title.selectable = false; button[s].title.htmlText = pages[s]; // Aligning button[s]._x = (button[s-1]._x + button[s-1].title.textWidth) + spacing; // Functions button[s].buttonNo = s; button[s].onRollOver = function() { if(this.buttonNo != page){ select = new Color(this); select.setRGB(0x000000); } activeNo = this.buttonNo; SWFAddress.setStatus(pages[activeNo].toLowerCase()); } button[s].onRollOut = function() { if(this.buttonNo != page){ deSelect = new Color(this); deSelect.setRGB(0xFFFFFF); } SWFAddress.resetStatus(); } button[s].onRelease = function() { activatePage(activeNo); } } };
// SWFAddress handling SWFAddress.onChange = function() { var value = SWFAddress.getValue(); // If URL is direct check witch page it is if (isNaN(activeNo)) { pagename = value.substr(1, value.length).toUpperCase(); getPageURL(); } // HTML Title var title = 'TITLE'; var names = SWFAddress.getPathNames(); for (var i = 0; i < names.length; i++) { title += ' - ' + names[i].substr(0,1).toUpperCase() + names[i].substr(1); } SWFAddress.setTitle(title); }
// Activate Page from URL name function getPageURL() { for (s=0; s<hoofdmenutotal; s++) { // Loop through pages to check witch is the right one pages[s] = hoofdmenuitems[s].attributes.title; if (pages[s] == pagename) { activatePage(s); } } }
// Activate Page function activatePage(p:Number) { var showFunctie = eval("show"+tmpl[p]); var hideFunctie = eval("hide"+tmpl[p]); if (tmpl[p] == "link") { var link = hoofdmenuitems[p].firstChild.nodeValue; getURL(link, "_blank"); // If it's a page } else { if (isNaN(page)) { Status ++; showFunctie(p); selectActive(p); SWFAddress.setValue(pages[p].toLowerCase()); page = p; } else { if (page != p) { if (tmpl[page] == "werk") { randomBG(); var movie:MovieClip = eval("hoofdmenu.content."+tmpl[page]); movie.removeMovieClip(); eval("imageflow_"+current).removeMovieClip(); image_info.removeMovieClip(); } else { var movie:MovieClip = eval("hoofdmenu.content."+tmpl[page]); movie.removeMovieClip(); } showFunctie(p); selectActive(p); SWFAddress.setValue(pages[p].toLowerCase()); page = p; } else { Status = 0; page = NaN; SWFAddress.setValue(""); deselect(); hideFunctie(); } } } };
Thanks for your time!
Cheers
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|