Tutorial 2-how to show Interstitial ad in air appadmin To Published in 2015-07-09 flash air( Read:2481

Tutorial 2-how to show Interstitial ad in air  app
package
{
import com.keymob.KeymobAd;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class InterstitialDemo extends Sprite
{
public function InterstitialDemo()
{
super();
KeymobAd.getInstance().initFromKeymobService("1");
stage.addEventListener(MouseEvent.CLICK,onClick);
}
protected function onClick(event:MouseEvent):void
{
if(KeymobAd.getInstance().isInterstitialReady()){
KeymobAd.getInstance().showInterstitial();
}else{
KeymobAd.getInstance().loadInterstitial();
}
}
}
}

1. init Keymob,we init keymob from www.keymob.com,app ID is 1.
KeymobAd.getInstance().initFromKeymobService("1");

2.add click event handler,each time click try to show Interstitial, it is similar with game over event.
if(KeymobAd.getInstance().isInterstitialReady()){//Check that the ad has loaded
KeymobAd.getInstance().showInterstitial();//show Interstitial if it is loaded }else{
KeymobAd.getInstance().loadInterstitial();//not loaded ,try to load again.
}

load Interstitial  every time Interstitial  is shown 
3.sample code in flash cc 
import com.keymob.KeymobAd;
import flash.events.MouseEvent;
KeymobAd.getInstance().initFromKeymobService("1");
stage.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void
 {
if(KeymobAd.getInstance().isInterstitialReady()){
KeymobAd.getInstance().showInterstitial();
}else{
KeymobAd.getInstance().loadInterstitial();
}
 }

0 Reviews,0 Participation.

Previous Next 0

Latest comments

No comment Oh!