Ok, the subject may not make sense, but here’s what I’m trying to do.
I have a menu done in Flash. I’m also using Ajax to switch up the main content div when someone clicks on the menu. So far this is working fine. What I’m trying to do is have the menu item that’s selected reflect that in some way (i.e. be in a “selected” state). That too is simple enough in itself.
The problem is that the Ajax script refreshes the page every time it’s executed. I can use a shared object within Flash to set which one should be selected, that too is not a problem. The problem then is that if I do that, it remembers which tab should be selected if the user closes the browser window and comes back later.
My idea was to have it set a cookie using <body onUnload=>, look for the cookie using javascript, and then if it was there pass a variable to the flash applet. The problem is it’s not passing the variable, and Firebug is giving me an error saying that SetVariable is not a function (I’ve also tried “setVariable” with the same result). Any ideas?
// calls this when the page is loaded
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
if (document.cookie == "mysite=visited") {
var flashMovie = getFlashMovieObject(tab); // "tab" is the id of the flash <object>
flashMovie.SetVariable("/:closed","true");
}
...
<body onUnload="closedBrowser()">
...
function closedBrowser() {
document.cookie = "mysite=visited";
}