MochiAds in haXe
January 12, 2010 at 7:34 pm | Posted in Flash games, Game development, HaXe, Programming | 5 CommentsTags: HaXe, mochiads, swfmill
I’ve been using haXe at work for a current project, and while things have been working pretty well so far, one thing proved to be a little more troublesome than we expected. We tried integrating MochiAds highscore API into the game, following hesselboom’s guide, but whatever we did, all we got was a broken game. No MochiAd pre-game ad, nothing, just a white screen. That’s not a good thing, considering that integrating it into an Actionscript project is supposedly a 5-minute job.
To give a little more insight, all game assets are packed into a .swf file using swfmill. The process is automated with a Python script, so all images, sounds and fonts are lumped together into archive.swf. When compiling the haXe code, this .swf file is passed along, so the code gets compiled into the .swf, to produce the final game .swf. Hesselboom’s guide suggested embedding the mochi library and the assets .swfs into one archive .swf. We first tried to just embed the mochi library .swf into our archive .swf, but that didn’t work. We then tried embedding both into a new .swf, but that didn’t work either.
My coworker did get MochiAds working in a new project though, just not in the actual game. So I started analyzing the swfmill output and I noticed something interesting. The fonts were giving trouble. Apparently swfmill can’t handle the case where an embedded .swf file contains already embedded fonts. However, embedding the fonts into the final .swf didn’t solve the problem…
In the end, I tried something silly: changing the embedding order of the library and the assets .swf. Guess what? It worked!
So just in case you’re working with haXe and integrating MochiAds fails – swapping two lines in your swfmill xml file might just do the trick. :)
5 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a Reply
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.
[...] Continue reading here: MochiAds in haXe « Create-ivity [...]
Pingback by MochiAds in haXe « Create-ivity | haXe WebDev Insider— February 2, 2010 #
That is very interesting. Did you try using SamHaXe to combine the two swf files? If so, did it have the same problem and solution?
Mind if I add a link to this page on my ‘Using MochiAds in haXe’ page?
Comment by hesselbom— February 4, 2010 #
[...] MochiAds in haXe « Create-ivity [...]
Pingback by Creating your first PHP application with HAXE | haXe WebDev Insider— February 8, 2010 #
Sorry, I haven’t had the time to try SamHaXe yet – but I’ll give it a shot once I’ve got some more spare time. I’ll keep you up-to-date. And sure, go ahead and put up a link. Thanks. :)
Comment by Pieter Witvoet— February 15, 2010 #
I faced the exact same problem, and I tried your solution, but no luck :(
It seems to me that if I use swfmill to include the mochi.swf into any other flash and have it my HaXe project using -swf-lib, it WILL break everything. I can’t even throw an error in the first line of code and see it.
Funny enough, using the mochi.swf directly without any assets seems to work.
Comment by Drakim— July 27, 2010 #