check if swf is a local or online file
AS3 October 5th, 2009Often, when projects become bigger and more complicated, it often is necessary gto let the application behave different when exported within the IDE and the actual LIVE project. I use this snippet, right at the beginning of my baseclass, to define in which environment the flash client is running:
Actionscript:
-
if(stage.loaderInfo.url.indexOf("file:") != -1){
-
_configXmlPath = "config.xml";
-
trace("local file");
-
}else {
-
trace("Server");
-
domain = URLUtils.getDomain( stage.loaderInfo.url);
-
}
I hope this is seflexpainatory.
January 28th, 2010 at 2:37 pm
Just wanted to say thanks, I needed this. Better than the way I had this setup. I was changing a variable to true or false depending whether it was local or online.