How to Sitelock a Game
Dec.08, 2008 in
Flash Actionscript
If you’ve ever found yourself wishing that there was a way to keep your game on just a couple sites without it spreading, then it sounds like sitelocking is what you need. Sitelocking allows you to ‘lock’ your game to a site, or a couple sites, so when someone tries to play it on another site it will be unplayable. It’s useful when you are uploading an unreleased game or are selling a non-exclusive license to a site. Here’s how you can sitelock your game. In this code I am using ActionScript 2.
urls_allowed = ["mindjolt.com" ,"www.mindjolt.com" ,"myspace.com" ,"www.myspace.com" ,"facebook.com" ,"www.freelanceflashgams.com" ,"freelanceflashgames.com" ,"devstatic.mindjolt.com" ];//sets up an array that stores the sites which you want to be sitelocked. sitelock(urls_allowed);//runs function sitelock function sitelock(urls_allowed) {//sets up sitelock function lock = true;//sets variable lock to true domain_parts = _url.split("://");//allows for a :// in the domain name real_domain = domain_parts[1].split("/");//allows for a / domain.text = real_domain[0]; for (x in urls_allowed) { if (urls_allowed[x] == real_domain[0]) {//if the domain is correct lock = false;//sets variable lock to false } } if (lock) {//if locked _root._visible = false;//the flash is invisible. } }
Related posts:



April 1st, 2009 at 8:06 pm
Why use split? Doesn’t it just open up for errors.
Wouldn’t it be fine to just use substring and just compare the beginning of the url to “http://www.mydomain.com”? Or would that have a problem?
April 3rd, 2009 at 9:16 pm
Yeah, that code is a bit outdated. I’ll be releasing a post soon with code that is much easier and simpler to use.
January 15th, 2010 at 6:20 am
There are ways to download the SWF file and to convert it to an FLA. if some one want to hack your game, this code won’t help.