If you are using ActionScript 3 in your project, you can use our SWC library created to facilitate the integration of our API in your game.Download Game Example Source
This is a step-by-step guide how to integrate the Click Jogos API in your game.
We create a SWC library to make the API integration a simple and fast process. You can add this library to your ActionScript 3 project by downloading here:Download SWC Library v0.0.4
After including the SWC library in your project you need to instantiate the API. You can do it with:
Once you instantiate the API, is very important that you initialize it using the method initializeAPI(), allowing all of the request to be authenticated. You can do it with:
Obs: The Developer Key can be obtained in the edition of your developer profile after you register in the DevCenter, and the Game Key in the edition of the game after you register it with success in the DevCenter
Now that you instantiated and initialized the API you must insert event listeners in your game to listen for the return of all functions and use the data from our back-end.
In our API each event listener belongs to a specific package of functions. You can read more about in the specific documentation for each language.
After adding all of event listener for the functions that you intent to use, you are able to call them. Remember that the API's functions are separeted into packeges to take the manipulatyion more easy.
Now you can send any event in your game to Click Jogos, so you need to create the stats and the achievements that will be delivered for users.
The submission process for games is very easy and simple, after insert the game name, the description, create stats and achievements, you just need to select the file of your game, insert the width and heigth of the frame, read and accept the terms of licence of the API, and submit.
After upload your game with success you will see a button where is possible take a preview of your game and test sending of stats and the delivering of achievements. This button can also be seen in the edition of your game.
You can load the API in your AS3 game, including our SWC library in your project.
After including the SWC library in your project, you'll be able to send parameters ans call the API functions without use the ExternalInterface class, it is recommended that you instantiate the API in a variable, although you can use it directly.
If you opt to use our library SWC, you will be able to initialize the API using the API function initializeAPI(developerKey:String, gameKey:String) , after instantiating the API.
This function authenticates all of the requests done in our server. Its receives two string parameters, the first is the developer key (that is received after registering on our DevCenter), and the second is the game key that is received after registering the game in our servers.
Similar to AS2 use, you must insert event listeners in your game to listen for the return of triggered events, and use the data from the back-end of Click Jogos.
The difference is that the SALT parameter don’t need to be sent along with the functions, this is done automatically.
There is two kinds of event listerners, success event listeners, and error event listeners.
The event listeners from users package belongs to CJApiUsernameEvent events, with corresponding there is error and success events. The event onGetUsername() returns ‘Guest’ if the current user is not logged in, or if the user is logged its return 'Username logged'. The event onGetUsernameErrors() returns false for success and an array containing the errors.
The event listeners from stats package belongs to CJApiAccountEvent events, with corresponding there is error and success events. The event onSubmitStat() returns true for success, if there is an achievement to be released is returned its name, the stat type and current value of the stat. The event onSubmitStatError() returns false for success and an array containing the errors.
The event listeners from service package belongs to CJApiAccountEvent events, with corresponding there is events to error and success. The event CJApiAccountEvent events, with corresponding there is error and success events. The event onIsSignedIn() returns ‘Guest’ if the current user is not logged in, or if the user is logged its return 'Username logged'. The event onIsSignedInError() returns false for success and an array containing the errors.