Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Anti-Theft Techniques
Your Ad Here

Anti-Theft Techniques


Anti-Theft TechniquesWe've all been there: you release a killer new flash movie or game and in days it's on sites that you never gave permission to host it. What can you do? How can you track down all these sites and get them to remove your file? Some sites won't take your file down even if you ask them to, so here's how you can protect yourself and your files as well as know when your files are being stolen.

First let me say that there are services that allow you to track your flash movie, but these services don't let you stop people from stealing them. What I'm going to show you is A) how to block a site from hosting your file (like the thieves at ebaum's world) and B) how to make your flash video 'call home' and when it does, check to see if it should be disabled. This trick relies on you having someplace to host a second swf, so if you can't do that, you'll have to find another way to do this. Let's get started.

The first way to stop a thief is to block their site from using your file. This can be achieved by placing code to detect their site and not allow you movie to play. This code should do the trick:

// URL Checker
checkIt = this._url.substring(8,this._url.indexOf( "/", 8 ) );
// Enforcer
if (checkIt.indexOf( "SiteToBlockHere.com" ) != -1) {
  stop();
}

What the code does is check its location and if it matches "SiteToBlockHere.com", then it stops your movie. Place this code in a reoccurring movie clip for maximum effect. That way, the thief can't have your movie start at the frame after the stop code, thus defeating your code. If you using it in a game, place the code on enemy spawn code or in your hero's walking code. If it's in a video, toss it in ever 200 frames.

So that's the easy way to block 1 site from using your flash file, but what if you want something a bit better? You could always change the script so that it only allows 1 site so that it works on your site but not on other sites, but maybe you want to give copies to other people and you don't want to edit the code every time you let someone host it. Here's where having a file 'call home' is helpful.

What we're going to do is have your file load an XML file from your site to both track a thief and thwart them. First, you need to create the XML file. In your favorite text editor make a new file (you can create an empty action script file in flash) and insert the following:

<?xml version="1.0"?>
<antiTheft>
<banned site="someSite.com" />
<banned site="someOtherSite.com" />
</antiTheft>

You can change, add and remove the <banned site="" /> tags as needed. Save the file and call it something like 'banned.xml' and then upload it to your site (upload it anywhere you want, just know where you put it). Now that that's done, go into the flash video you want to protect. All you need to do is tell you flash file to read that XML file and not run if it's on a banned site. Simple, right? Well, actually, it is. Here's how you do it:

// URL Checker Setup
checkIt = this._url;
checkIt = checkIt.substring(7, checkIt.indexOf("/", 8));

data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
  if (success) {
    var track_xml = data_xml.firstChild.firstChild;
    while (track_xml != null) {
      // Enforcer
      if (checkIt.indexOf(track_xml.attributes.site) != -1) {
        stop();
      }
      track_xml = track_xml.nextSibling;
    }
   else {
    //server down/file missing
    stop();
  }
  delete data_xml;
};
data_xml.load("http://www.yoursite.com/banned.xml");

Be sure to change the last line to match the path to your ban file!

What the code does is 2 things. First 'checkIt' is set to the site that the flash video is playing from. If you were to put you movie at 'http://www.yoursite.com/videos/movie.swf', checkIt would be set to 'www.yoursite.com'. The next thing it does is load your banned.xml from your server and checks if it's on any of the banned sites. If it matches a banned site to its location, it'll halt the movie playback. Also, if it can't connect to your server it won't play.

This technique is simple, effective and super fast. Also, having you flash files call home is a nice way to track them. If you look at your server logs (or server stats) you can see who's requesting your banned.xml file, and track down people who have stolen your file(s). This allows you to ban sites as you find out about them and not block all sites which could block legitimate sites. A possible extension to this is adding a 'file' property to each 'banned' tag so that it reads <banned site="someOtherSite.com" file="myVideo" /> and have the videos detect if the ban rule applies to them or not. That way you can have your videos banned on different sites.

The only weakness to this code is that if someone hotlinks your movie, it'll still work as it'll be loading from your server. The only way to prevent that is to implement anti-hotlinking code on your server.

Enjoy and don't let thieves get rich off your flash files!



Author's URL: FlashSandbox
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Anti-Theft Techniques"

Only registered users can write comment

Reader's comments