ChartBoost is a native extension to use ChartBoost advertisements. This extension was developed by the ChartBoost team, so it provides an official implementation of the service API. The extension works on Android and iOS, allowing developers to use the same set of methods on both platforms.

The extension has methods to cache and show different types of ads, such as¬†interstitials and “more apps”. Several events are available to inform the current state of the extension, e.g. ad was cached, ad was showed, ad dismissed, ad failed to load. The extension itself is also able to inform the developer if the system it’s running on is Android or iOS.

Sample

import com.chartboost.plugin.air.Chartboost;
import com.chartboost.plugin.air.ChartboostEvent;

private var chartboost:Chartboost;

private function init():void {
	localTrace("Chartboost Actionscript init()");
	// init
	chartboost = Chartboost.getInstance();
	if (Chartboost.isAndroid()) {
		chartboost.init("4f7aa26ef77659d869000003", "ee759deefd871ff6e2411c7153dbedefa4aabe38");
	} else if (Chartboost.isIOS()) {
		chartboost.init("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");
	}

	// add listeners
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_CACHED, onAdCached);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_SHOWED, onAdShowed);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_DISMISSED, onAdDismissed);
	chartboost.addEventListener(ChartboostEvent.INTERSTITIAL_FAILED, onAdFailed);
}

private function onAdShowed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial showed: ", event.location );
}

private function onAdCached( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial cached: ", event.location );
}

private function onAdDismissed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial dismissed: ", event.location );
}

private function onAdFailed( event:ChartboostEvent ):void {
	localTrace( "Chartboost: on Interstitial failed to load: ", event.location );
}

public function localTrace(log:String, log2:String = ""):void {
	logs.text = logs.text + "\n" + log + " \t" + log2;
}

Chartboost.getInstance().cacheInterstitial();
Chartboost.getInstance().showInterstitial();	
trace(Chartboost.getInstance().hasCachedInterstitial().toString());

Chartboost.getInstance().cacheMoreApps();
Chartboost.getInstance().showMoreApps();
trace(Chartboost.getInstance().hasCachedMoreApps().toString());
Air Native Extension, Android, iOS . URL.