feedback
Oct 26 2007

Is another site/URL using my Flash SWF?

by John Dyer

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.

Comments

Evan Mullins November 12. 2007 10:12

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?

Evan Mullins

Evan Mullins December 18. 2007 15:34

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?

Evan Mullins

John Dyer December 18. 2007 16:18

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.
John Dyer's last post: Wii + Flash + Papervision3D + C# = Alumni World Map

John Dyer

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading