Finding the domain name where the swf is being served

There are fimes when I would need to verify the domain name where the swf (embeded in an html page) is being served. I have done some testing and it seems that the following client-side AS3 code would do the job.

import flash.net.LocalConnection;
var lc:LocalConnection = new LocalConnection();
trace (lc.domain);

When I uploaded the swf and the html page to a web server, it did return the domain name of the server where the page and the swf are being hosted.

I hope this tip is useful for you too. 🙂

Advertisements

~ by brianchau on June 19, 2009.

One Response to “Finding the domain name where the swf is being served”

  1. thanks! it is very useful, i’ve used
    ExternalInterface.call(“self.location.href.toString”);
    before to detect domain. it was providing additional info (like the full path, not domain only), but required allowScriptAccess set to “always”.

    thanks again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: