Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to upload my game to Kongregate and other sites, but on Kongregate I want to invoke one function and other sites I want run another function. How to check in AS3 where (I want to get host like: www.kongregate.com or www.games.com etc) my game is? Or maybe you know other, better way to make this?

share|improve this question

1 Answer 1

I found a post on how to site-lock flash movies/games here. It is the fourth post down. You can modify it slightly to make it do something or set any variables you need changed.

Here is the code from the post.

//Assuming you have a movieclip or sprite named myMovieClip (you can use any movieclip or sprite)
var URLofSWF:String = myMovieClip.loaderInfo.loaderURL;

//You will do some string methods to get domain name etc etc, it's up to you
var domain_parts:Array = _url.split("://");
var domain_parts_2:Array = domain_parts[1].split("/");
var domainOfURL:String = real_domain[0];

 //Then you compare the URL to any URL you wish to allow or disallow
if(URLofSWF == "http://www.google.com/mySwf.swf"){ // strict swf url checking
proceed();
}else{
stopEverything(); // Or inject some funny code to the stealer :P
}
// or 
if(domainOfURL == "www.mysite.com"){ // domain checking only
    proceed();
}else{
    stopEverything(); // Or inject some funny code to the stealer :P
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.