Solved

Check domain before play

Posted on 2006-11-25
8
204 Views
Last Modified: 2010-04-03
Hi experts,

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

Thanks
0
Comment
Question by:cabou
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:blockage1
ID: 18012287
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)
0
 
LVL 5

Expert Comment

by:blockage1
ID: 18012290
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
}
0
 

Author Comment

by:cabou
ID: 18012305
ok, but I need to check the domain and not the page

thanks
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 13

Expert Comment

by:FLAASHER
ID: 18012308
try this :


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




FLAASHER
0
 
LVL 13

Accepted Solution

by:
FLAASHER earned 250 total points
ID: 18012320
sorry :

this is the complete code :



host = new LocalConnection();
if(host.domain() == "www.urdomain.com"){
      gotoAndStop(30);

      }else{
            //dont play
            }

stop();



put it in ur frist frame


FLAASHER
0
 
LVL 13

Expert Comment

by:FLAASHER
ID: 18012336
i tested the new version and it works fine

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






FLAASHER
0
 
LVL 5

Expert Comment

by:blockage1
ID: 18012354
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.
0
 
LVL 13

Expert Comment

by:FLAASHER
ID: 18012426
Thanks for the points









FLAASHER
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question