There is not a clear way in Flash access what site is using your SWF. On DTS's media page, we allow users to embed our media player in their blogs (like all other video sites these days), but it is difficult to know the URL of the file who is pulling the file. stage.loaderInfo.url is just the URL of the SWF, but not the HTML page which embeds the SWF. The only way I found to do this is to call ExternalInterface and ask JavaScript what the URL of the page is. So here's what I came up with:
var urlReferrer:String = ExternalInterface.call("document.location.href.toString");
The reason for the "toString() is that ExternalInterface.call wants you to use a function rather than just calling a static property.
Update (01/08/08): Looks like someone else has caught on to this.
Thanks! I was having trouble with this- until you pointed out the toString has to be called. Makes sense, why didn’t I think of that?
Actually this doesn’t seem to be working with msie 6 or 7.
Works like a charm for firefox and any others I’ve tested…
Any suggestions?
I’ve noticed that it works in IE when you use SwfObject (http://blog.deconcept.com/swfobject/) or when use both the object and embed tags, but it won’t work if you only use the embed tag.