Link to home
Start Free TrialLog in
Avatar of cabou
cabou

asked on

Check domain before play

Hi experts,

I need to protect a flash movie. so how can I check that it is playing on my server?

Thanks
Avatar of blockage1
blockage1

This will check if the file is being served from you domain:

if ( _url == "http://www.yourdomain.com/filename.swf" ) {
    // yes it is
} else {
   // no it isn't
}

To make this work replace "http://www.yourdomain.com/filename.swf" with the full url to your swf (including the quotes)



You will also need to make sure the swf isn't being hot linked from your server....

import flash.external.ExternalInterface;
var url = = ExternalInterface.call( "function(){return document.location.href;}" ).toString;
if ( url == "http://www.yourdomain.com/containerpage.html" ) {
    // yes it is
} else {
   // no it isn't
}

To make this work replace "http://www.yourdomain.com/containerpage.html" with the full url to the page holding your swf (including the quotes)
That should be...

import flash.external.ExternalInterface;
var url = = ExternalInterface.call( "function(){return document.location.href;}" ).toString();
if ( url == "http://www.yourdomain.com/containerpage.html" ) {
    // yes it is on your own page
} else {
   // no it is not on your page
}
Avatar of cabou

ASKER

ok, but I need to check the domain and not the page

thanks
try this :


if(host.domain() == "www.urdomain.com"){
      //play me
      }else{
            //dont play
            }




FLAASHER
ASKER CERTIFIED SOLUTION
Avatar of FLAASHER
FLAASHER
Flag of Saudi Arabia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i tested the new version and it works fine

just put it in ur frist frame and modify it with ur domain name






FLAASHER
That wont stop users hotlinking to your swf. This will...

var url = ExternalInterface.call( "function(){return document.location.href;}" ).toString();
if ( url.indexOf("www.yourdomain.com") == 7 ) {
    // yes it is on your own page
} else {
   // no it is not on your page
}

If you have subdomains you'll need to have seperate if statements for them too.
Thanks for the points









FLAASHER