Actionscript:
-
private var _correctPath:String;
-
-
//.... somewhere a little later
-
-
if (root.loaderInfo.url.split("http://").length == 1){
-
_correctPath = "http://www.mywebsite.com/this/is/an/absolute/path/";
-
}else{
-
_correctPath = "";
-
}
I like to do something like this when I'm working locally... it automatically tells my swf to use an absolute path for php files, xml files etc.... then, when I upload it, the LoaderInfo.url property contains an "http://" so it uses a relative path for all the external files. This is common especially if you don't have php and mysql installed on your machine and need to test these using your server.
4 Comments
I’ve got something like this wrapped in a class called Environment for AS2 and AS3.
Here is the AS2 version:
http://evolve.reintroducing.com/2008/11/14/as2/as2-environment/
And here is the AS3 version:
http://evolve.reintroducing.com/2007/10/15/as3/as3-environment/
very cool Matt…. took me awhile to figure out how to do it in AS3 the first time I needed to…. that whole root.loaderInfo thing was confusing at first….
Hi Zevan! i´m been on your blog for the last hour provably. you have very nice examples. I´ll be back for sure.
I just read this post, and i would like to share my one line of pure magic code:)
this is a public static var i have in my document class. so, ican access it from anyclass
public static var LOCAL:String = Security.sandboxType != Security.REMOTE ? “http://www.mywebsite.com” : “”;
All the best
andre
very nice andre… glad your enjoying the site.