Is This swf Online?

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

  1. 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….

  2. 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

Leave a Reply

Your email address will not be published. Required fields are marked *