MochiMedia Ads

Monkey Targets Forums/Flash/MochiMedia Ads

Monking(Posted 2013) [#1]
I had done a simple game and testing on MochiMedia Ads API to show pre-game Ad, but it won't work for me.

I found this forum:
http://monkeycoder.co.nz/Community/posts.php?topic=735

Unfortunately it is 1 year ago forum, the MochiMedia api did some changes? (I guess) as var _mochiads_game_id:String = "xxx"; is not included in api, it came with something like this:

import mochi.as3.*;
MochiAd.showPreGameAd({clip:root, id:"yourid", res:"800x600"});

I included it inside MonkeyGame.as like this:
public function MonkeyGame(){
			MochiAd.showPreGameAd({clip:root, id:"yourid", res:"800x600"});
			game=this;

			addEventListener( Event.ADDED_TO_STAGE,onAddedToStage );
			
		}

However, it show a light-blue page and nothing show out. :(
I need help !
Thanks for expert comments in advanced.

(I did add the trusted location for this file but it won't work either)


Jesse(Posted 2013) [#2]
For the pre game adds all you need is the game Id you get when you create a new game submission.
Add it to the game and recompile it. That is all. You don't even need the Mochi API.

I did it that way a few months ago after the new API came out and It worked so I am assuming it still does.


bazmonkey(Posted 2013) [#3]
Can you try opening the swf in the debug Flash player, it often gives a proper error message there (on top of the blue background).


Monking(Posted 2013) [#4]
Monkey Runtime Error : TypeError: Error #1034


bazmonkey(Posted 2013) [#5]
Hmm, ok. maybe its the 'root' clip?

This is my code (monkey 72b) :
http://code.google.com/p/congo-monkey/source/browse/trunk/mochi/native/mochiwrapper.flash.as

The code that monkey generates changed quite a bit from v69 to v72b, as mentioned in the comment. I will tidy it up some time, but it definitely works since I used it in the mochi summer dev contest.


Monking(Posted 2013) [#6]
Hi bazmonkey, thanks for your reply.
Actually, I did read the forum from http://www.monkeycoder.co.nz/Community/posts.php?topic=2264

However, I have no idea how to include it,
I copy the codes and place it inside the following path:
1 - modules/mochi/mochi.monkey
2 - modules/mochi/native/mochiwrapper.as

What I did is change the "xxx" to my id, but it is nothing actually.
What is the coded needed to include such file ?

(Sorry I'm totally new to Monkey)


bazmonkey(Posted 2013) [#7]
The way modules/files are imported is quite flexible -- see main language docs under 'Modules'. Its similar to 'include' paths in other languages. You can either copy code to the main monkey modules folder, or use a local copy, so its up to you.

In your case 'Import mochi' should be enough, since it will search both paths for the file. Note, it also looks for mochi/mochi.monkey, so a folder can optionally be used. Modules can import other modules. Hence, I can import my entire module using just 'Import congo'.

My current way of doing mochi is:

Register a new game in the mochi dashboard to get the game id.

Add my id to the *generated* MonleyGame.as code, so it looks like this:

public class MonkeyGame extends Sprite{
	public var _mochiads_game_id:String = "xxxxxxxxxxx"; [YOUR ID HERE]
	public function MonkeyGame()
		// … etc

(If you're new to monkey, editing the generated files might seem a bit strange, and it can be confusing if you later do a clean rebuild. But, for now I do it that way, since I know it works...)

I then call my MochiWrapper.ConnectToMochi( "xxxxxxxxxxx" ) early on, e.g. during an intro/splash screen. This just calls the mochi sdk MochiServices.connect. Might only be required for leaderboards, actually -- not sure.

Thats pretty much it. I then call up whatever ad units I need, e.g.
MochiWrapper.ShowInterLevelAd( "xxxxxxxxxxx", "550x550" )

Yes, I realise I put the id in every call which is ugly, I should just store it :-P
If any actionscript arguments are invalid, I tend to see that TypeError and blue screen.


Monking(Posted 2013) [#8]
What I did with step by step:
1 - Copy 2 files from http://www.monkeycoder.co.nz/Community/posts.php?topic=2264 and places inside modules (follow the path)

2 - Write Import mochi at my main game class file

3 - Compile it (Flash, Release)

4 - Go into gameName.build/flash/MonkeyGame.as

5 - Add this line public var _mochiads_game_id:String = "xxxxxxxxxxx"; [YOUR ID HERE] right after public var runner:Function;

6 - Compile the game again

7 - Open the game, my game shows up but not mochi load bar.. = =


bazmonkey(Posted 2013) [#9]
Seems ok. Flash stuff is quite hard to test/debug, you're probably almost there. I'd try to submit some scores, see if the score widget appears, and show an ad too -- see which bits are working.

The mochi dashboard (webpage) also tells you if your game has made a successful ad request.

Not sure what you mean by 'mochi load bar' -- remember that a lot of mochi games use the Live update preloader, or a separate preloader (as you've seen in the other thread). I think this is what Jesse is saying in his reply - sry if I confused you.

If doing MochiServices.connect you should briefly see a spinning icon in the corner.


Monking(Posted 2013) [#10]
Oh is that ?
Actually what I'm intend to do is simple, show the pre-game Mochi Ads..


bazmonkey(Posted 2013) [#11]
Its up to you - if you upload via the Live update feature you will get their preloader and initial advert added automatically. You can customise the preloader a little via the dashboard. Still add your mochi id to MonkeyGame.as, but aside from that it requires no extra coding (their server returns you a modified swf).

Or, you can code your own preloader and use showPreGameAd yourself, and not use Live updates.

Ultimately, you'll probably want to get the scoreboard wrapper function working anyway, its pretty cool. And, you might want to show other ad types, or at specific times (interlevel ads, showcase ads, etc). Having just a single ad before your game is fairly limiting.

Theres actually a dashboard option to show an ad automatically after every score submit, but I find that a bit much to show every time. I quite like the new CPA/Showcase widgets (I added them to my wrapper).


Monking(Posted 2013) [#12]
Oh, I get it now !
Thank you bazmonkey. You're such a kind person. Thanks !


bazmonkey(Posted 2013) [#13]
Well, Jesse actually answered correctly first time... ;)
(when you asked about the api wrapper calls, I assumed you wanted to use those!).