Detecting Kongregate API

9 posts

Flag Post

Is there a way to detect that the API is available so I can make one version of my game that I can use on other sites?

ie. Take URL locking – you can check the url of the host of the swf file and if it is not on your server, change in to demo mode.

So, if my swf doesn’t detect the api, it knows it is not running on the Kong server and doesn’t try to use them? Or the opposite situation, it detects via url locking that it’s not running on my server, but it also detects the Kong api so it still runs as the full version?

 
Flag Post

You can run games with the Kongregate API fine on other sites.

Kongregate puts your swf inside a shell, and you access its methods by using _root.kongregateServices.

On another site, _root.kongregateServices won’t be anything, so any functions you call on it will silently fail and your game will continue to run past them.

 
Flag Post

I am interested as well to find a way to detect if my SWF’s are on Kongregate or not, (if they were stolen) but using the API isn’t going to be a good method.

The reason why is because it goes through the chat window, so anytime someone doesn’t have that window available (Ie. they are behind a firewall that doesn’t have port 5222 open, like me right now) it will not detect the api’s and then fail. (or in your case run the wrong version)

 
Flag Post

@Caimbul: Some standard URL locking code should do fine there.

 
Flag Post

Good point Kalinium – I suppose it’s just a case of checking for kongregate.com in the _url

 
Flag Post

You can try this

<pre> if (_root.kongregateServices == null){ // Kongregate API not available

}

or Inversely

<pre> if (_root.kongregateServices != null){ // Kongregate API is available

}

 
Flag Post

I think instead of null you’d need to check against undefined. Or better yet, just check it as a boolean


if (_root.kongregateServices) {
// Kongregate API is available
}

 
Flag Post

Heh I’ve forgotten what they use in AS2.0 ^^ Been at Java for a year now.

 
Flag Post

Some good suggestions