hesselboom

Using MochiAds in haXe - April 17th, 2009

I recently created a flash game using haXe and swfmill. Now I wanted to use both MochiAds version control and MochiAds leaderboards in the game.

For the version control I simply added a new game from the MochiAds dashboard, after logging in, and followed the simple steps. No need to get more into this part. It's very simple really, and works fine in haXe.

For the leaderboards part it got a little more difficult.

First off I downloaded the latest MochiAds API (can be found on the dashboard under "Downloads") and found a ActionScript 2.0 version and one 3.0 version of the API. No haXe version. First I looked at the code to determine how long it would take to port it to haXe. I decided way too long.

To cut things a little shorter, I simply did like this instead:

compc -source-path . -output mochi.swc -include-classes mochi.as3.MochiAd mochi.as3.MochiDigits mochi.as3.MochiScores mochi.as3.MochiServices

or

compc -source-path . -output mochi.swc -include-sources .
Notes:
- You can look up compc syntax here
- If you don't have the free Flex SDK installed, get it at adobe.com
- If you don't have the flex folder in your PATH environment variable change 'compc' to the actual path
haxe --gen-hx-classes library.swf
<clip id="assets" import="assets.swf"/>
<clip id="mochi" import="library.swf"/>

That should be all. Now you should be able to use all MochiAds features in haXe. Enjoy!

If you are having any trouble or have any questions feel free to send me an e-mail at viktor.hesselbom at gmail.com

- Viktor Hesselbom