Solved

Check domain before play

Posted on 2006-11-25
8
200 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now