March 1st, 2009 | permalink
Hashtags and Flash
I have been looking for an answer to a problem that I have been having regarding Flash websites and being able to bookmark individual pages. It was not easy to find an answer to the problem, but after much research and help from friends pointing me in the right direction, I have been able to find an answer… Hashtags.
By using hashtags, I am able to update the address bar on anything that is clicked in the Flash application and then if a user bookmarks exactly where they are, they can get back to that page with another function that checks for the hashtag when the page loads. If it is there, I can have it perform a certain action based on its value.
Actionscript on my button:
getURL("javascript:show('"+_root.target+"')");
Javascript:
function show(txt){
document.location.hash = txt;
}
function getHash() {
return ( window.document.location.hash );
}
Then, if someone wants to send a link directly to that page, they can do so. I added more actionscript that checks for the hashtag in the url string when the page loads…
Actionscript:
//
import flash.external.ExternalInterface;
var myUrl:String = String(ExternalInterface.call("getHash", null ));
if (myUrl == null or myUrl == "undefined" or myUrl == undefined or myUrl == "null" or myUrl == "") {
_root.sec = _root.navigationArray[0].title;
} else {
myUrl = myUrl.substring(1);
_root.sec = myUrl;
}
goSec(_root.sec);
stop();












