I am making my first game in ActionScript
and I'd like to upload it to Kongregate
.
While implementing the Kongregate
API (using FlxKongregate from the Flixel Power Tools), I'm trying to find the best place to call the function to disconnect from Kongregate's servers.
I can't do this is any one of the game's states, since there's a few of them that the player can move between, so disconnecting whenever one of the states closes wouldn't make any sense.
Therefore I figured the best place to implement the Kongregate
API would be in the game's central registry (nothing but static methods), since that's always active in the background of the game.
What I'd like is a way to tell when the player is closing the game, and disconnect there. If I just write a dispose function, will it get automatically called? If not, what else can I do?
A short research indicates that you won't be able to write a function that's called when the user closes the browser. So you have several possible ways: