I just created a game for the miniLD and I wanted to try to implement the FGL ads, just for fun not too make any big money. I tryed to implemet them using this code for my Main class(I got most of it from emanuele feronato):
package
{
import net.flashpunk.Engine;
import net.flashpunk.FP;
import A;
import flash.display.StageQuality;
import flash.events.Event;
public class Main extends Engine
{
// variable declaration
private var ads:FGLAds;
public function Main()
{
super(640, 480, 60, false);
// FGL-56 is my game ID
ads=new FGLAds(stage,"FGL-xxxxxxx");
// waiting for the api to be ready to call showStartupAd
ads.addEventListener(FGLAds.EVT_API_READY, showStartupAd);
// should it take too long to load, let's skip the ad and call enableGame function
ads.addEventListener(FGLAds.EVT_AD_LOADING_ERROR, enableGame);
}
private function showStartupAd(e:Event):void {
// showing ad popup
ads.showAdPopup();
// waiting for the player to close the popup
ads.addEventListener(FGLAds.EVT_AD_CLOSED, enableGame);
}
private function enableGame(e:Event):void {
// removing listeners
ads.removeEventListener(FGLAds.EVT_AD_CLOSED, enableGame);
ads.removeEventListener(FGLAds.EVT_AD_LOADING_ERROR, enableGame);
// start the game
init();
}
private function init():void{
// here starts the game, which calls showGameOver function when the game is over
FP.world = new Start();
}
}
}
The ads shows up when I run it from within flashdevelope but then when I start it in a browser the game does not start at all. Do you have any suggestions?
*Fixed code formationg