0

I need to use a *.swf file in my Google blogger site,

So I upload my *.swf file to www.000webhost.com, because I think blogger not support to upload *.swf files and we need to use external storage for *.swf files.

Before to load the *.swf file in my site, it need to check the browser Url to prevent use it in another site.

So I tried

var myurl:String = loaderInfo.loaderURL;

and

var lc:LocalConnection = new LocalConnection();
var myurl = lc.domain;

but both gives the Url to *.swf file, not the browser Url.

How to get the browser Url to a variable in adobe flash?

1 Answers1

0
var swfURL:String = unescape( LoaderInfo( this.root.loaderInfo ).url ); // url of SWF
var domain:String = "google.com"; //make this your own domain

if ( swfURL.indexOf( domain ) >= 0 ) {
    // run swf
}
else {
    // Go Storm Saxon on their...
}

That takes the full URL of the SWF and simply checks to see if the domain is located in there. This can be fooled, obviously, if the person trying to steal your SWF happens to make a sub-directory that includes the domain. But for most cases, I would imagine this would suffice.

Josh
  • 8,079
  • 3
  • 24
  • 49
  • My *.swf file is in www.000webhost.com server. – Eranda Gunathilaka May 02 '13 at 01:57
  • My *.swf file is in www.000webhost.com server. Its Url looks like mysite.hostei.com/123.swf. But my blogger site Url looks like mysite.blogger.com/mypage.htm. I need to get my blogger site Url to a variable in *.swf file when it load. But all above variables give the Url to *.swf file, not to my site. – Eranda Gunathilaka May 02 '13 at 02:04
  • I see. Try this, then. A quick search and this was the first result on Google. [`ExternalInterface.call("window.location.href.toString");`](http://stackoverflow.com/a/2128533/1515620) – Josh May 02 '13 at 17:34