API Documentation

The MindJolt API is designed to be simple to integrate, but powerful in what it can do. By simply adding a few lines of code to your game, it will automatically harness the social features of each of the major social networks (Facebook, MySpace, etc.), be distributed to millions of players, and start earning revenue for you via MindJolt’s monetization platform.

Just follow these four simple steps:

#1. Register your game

Let us know some basic information about your game, so that we can assign it a GAME_ID. You will need this GAME_ID when you add the code below.

Register your game on the Manage Games page

#2. Install the API Library

To install the API Library in your game, simply download and add one of the following MindJoltAPI.as files to your flash project.

Pick the ActionScript library that is the correct version for your game:

#3. Connect to the platform, and earn money while players play your game

Add the following two lines (use AS2 or AS3 depending on your game). These should execute as soon as possible, when the game starts. This will connect to the MindJolt platform, show an advertisement to earn you revenue, and act as a preloader while your game is loading. Ideally, these two lines would be placed by themselves on the first frame of your game.

Make sure to replace “YOUR_GAME_ID” with the “GAME_ID” that was assigned to this game when you registered it in Step #1.

// AS3:
MindJoltAPI.service.connect("YOUR_GAME_ID", this, callback)
MindJoltAPI.ad.showPreGameAd({clip:this});
// AS2:
MindJoltAPI.service.connect("YOUR_GAME_ID", _root, callback);
MindJoltAPI.ad.showPreGameAd({clip:_root});

Parameters for MindJoltAPI.service.connect

  • "YOUR_GAME_ID":String – replace YOUR_GAME_ID with the GAME_ID that was assigned when you registered your game. Example: “JFAAFJJDF”
  • clip:MovieClip – the clip that our end of game screen and ad are loaded into. It should also be the clip that contains the flashvars. If for some reason you need to load those into some clip other than the default (“this” for AS3, “_root” for AS2), then you can change the reference to whatever you need it to be.
  • callback:Function – (optional) the function you pass in will be called after the API finishes connecting. You can use this to know it’s okay to make other subsequent API calls… for example the MindJoltAPI.service.submitScore(…) call down below.

Parameters for MindJoltAPI.ad.showPreGameAd

  • Note: the following parameters should be placed inside curly brackets { }
  • clip:MovieClip – the clip that our end of game screen and ad are loaded into. It should also be the clip that contains the flashvars. If for some reason you need to load those into some clip other than the default (“{clip:this}” for AS3, “{clip:_root}” for AS2), then you can change the reference to whatever you need it to be.
  • ad_started:Function – (optional) the function you pass in will be called before the ad starts. You can use this to know that the ad is starting, if you need to. By default, if no adStarted function is passed in, the API will automatically call stop() on the clip that is passed in.
  • ad_finished:Function – (optional) the function you pass in will be called after the ad is finished. You can use this to know that the ad has completed, if you need to. By default, if no adFinished function is passed in, the API will automatically call play() on the clip that is passed in.

Note 1: Ads will automatically show before the game starts, and when the player chooses to play again. (The MindJolt API will automatically insert an ad in between gameplays.)

Note 2: If you would like to sitelock your game, search for the simple string “mindjolt”. If you prefer a more secure path, mention this during your game acceptance process and we’ll provide a full akamai URL. However, as configs change, this will require some maintenance on your part. For now, the current site lock code to follow is:

var url:String=this.loaderInfo.url.toLowerCase();
if (url.indexOf("mindjolt.com")>-1)
{
trace(" is on Mindjolt servers, play game");
}
else
{
trace("not on Mindjolt servers, stop game");
}

#4. Integrate high score leaderboards

High scores are a key part of a game’s success on MindJolt. High scores fuel virality and growth on the platform, and mean the difference between success and failure for games on MindJolt. Luckily, all it takes is one line of code to integrate the MindJolt high scoring system. (All issues such as state, session and authentication are handled automagically behind the scenes!)

All games on MindJolt must provide the user with the opportunity to submit a score, as this helps incentivize users to play more often and share the game with their friends. (Trust us, we’ve tried, and games without high scores simply do not do as well on the platform.)

To add high scores to your game, all you have to do is call the submitScore function when the game ends, to submit the score.

// AS3 or AS2:
MindJoltAPI.service.submitScore(score:Number, gameMode:String=null, playAgainHandler:Function=null):void

Some examples:

// Example with game mode "easy":
MindJoltAPI.service.submitScore(yourScoreVariable, "easy", yourFunctionThatJumpsToMainMenu)
 
// Example with no game mode used:
MindJoltAPI.service.submitScore(yourScoreVariable, null, yourFunctionThatJumpsToMainMenu)

Parameters

  • score:Number – the score the user achieved
  • gameMode:String – (optional) only used if the game supports multiple game modes (“easy”, “medium”, “hard”, etc.) so that we can have separate high score leaderboards for each mode. If your game does not have multiple modes, you should not submit a gameMode.
  • playAgainHandler:Function – (optional) the function you pass in will be called after the end of game sequence (allowing the user to share their score, invite friends… and after the ad displays). Typically, you might pass in a function that would jump the user back to the main menu.

#5. Utilize Virtual Goods API to allow new monetization opportunities

Details of the Virtual Goods API are available on this dedicated page.

That’s it! Now you can upload your game .swf, test that it’s working, and let us know that it’s ready to start being distributed. You can do all of that on the Manage Games page.