I am working on a project where I would like Flash to be able to determine whether the browser is serving content over HTTP or on the user’s local drive.
I actually found the key bit of code for this from a great resource that BH has sent out a few times: Mr. Doob!
I expanded his code to redirect to a file depending on what environment it believes it is in:
var localMode : Boolean = loaderInfo.url.indexOf("file") == 0;
trace(localMode);
var serverMode : Boolean = loaderInfo.url.indexOf("http") == 0;
trace(serverMode);
if (localMode == true) {
loadPlayerInterface('default.html')
}
if (serverMode == true) {
loadPlayerInterface('default.asp')
}
function loadPlayerInterface(myFileName:String):void {
var url:String = myFileName;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_parent');
} catch (e:Error) {
trace("Error occurred!");
}
}