Admob sample code using Flash Builder

Image


 


You can use Flash Builder to develop application for Android and IOS. The IDE is similar to Eclipse. You can use the same code to develop for multiple platform.

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ns1="*"
title="This is hello World" viewActivate="onViewActivate(event)"
viewDeactivate="onViewDeactivate(event)">


<fx:Script>
<![CDATA[
import com.hdi.nativeExtensions.NativeAds;
import com.hdi.nativeExtensions.NativeAdsEvent;
import com.lancelotmobile.utils.DPIUtil;

import flash.media.StageWebView;
import flash.net.URLRequest;
import spark.events.ViewNavigatorEvent;

protected var webView:StageWebView = new StageWebView();
protected var openBrowser:Boolean = false;

import spark.events.ViewNavigatorEvent;


protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
if (StageWebView.isSupported)
{
currentState = "normal";
webView.stage = stage;
webView.viewPort = new Rectangle(0,75,stage.stageWidth,stage.stageHeight);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onURLChange);
webView.loadURL("http://google.com");
addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
}
else {
currentState = "unsupported";
lblSupport.text = "StageWebView feature not supported";
}
}

protected function onURLChange(event:LocationChangeEvent):void
{
trace("URL change");
// Uncomment the following line to load in the default browser instead...
//navigateToURL(new URLRequest(event.location));
}

protected function onRemove(event:ViewNavigatorEvent):void
{
this.webView.dispose();
}

protected function onViewActivate(event:ViewNavigatorEvent):void
{
NativeAds.dispatcher.addEventListener(NativeAdsEvent.AD_RECEIVED,onAdReceived);
NativeAds.showAd(0,DPIUtil.appHeight - 75,480,75);
}

protected function onViewDeactivate(event:ViewNavigatorEvent):void
{
//hide ads
NativeAds.hideAd();
}

protected function onAdReceived(event:Event):void
{
//Anything behind the ad will be hidden, update your layout to handle this edge case.
trace("update ui's size and position");
}

protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub

}

]]>
</fx:Script>


<s:states>
<s:State name="normal"/>
<s:State name="unsupported"/>
</s:states>
<s:Label id="lblSupport" includeIn="unsupported" width="95%" horizontalCenter="0" verticalCenter="0"/>

<s:VGroup paddingLeft="10" paddingRight="10" paddingTop="20">
<s:Label text="Ad Mob example" />
<s:Label width="100%"
text="This is our first example apps &#xd;using Flash Builder." />




</s:VGroup>

</s:View>

Admob sample code using Flash Builder Admob sample code using Flash Builder Reviewed by Admin on 12:42 PM Rating: 5

No comments:

Powered by Blogger.