Get SWF url path and domain name using AS3

In as2 you would use:
trace(_url);

Now in as3 you will have to use loadInfo:
trace(loaderInfo.url);

If you know there is a .com in the domain name, just do a split on the info using “.com”. Now the third item in that array (index 2) should be your domain name.
var swfDomain = loaderInfo.url;
var pathArray = swfDomain.split(“.com”);
trace(pathArray[2]); // should be yourdomain.com if on a web server

You may also like...

1 Response

  1. If you know there is a .com in the domain name

Leave a Reply