Quantcast
Channel: Adobe Community : All Content - AIR Development
Viewing all articles
Browse latest Browse all 2954

HTML Ad in Air for Android app using Flash CS6 (launching the native browser for banner clicks)

$
0
0

Hi guys, I am having difficulties integrating LeadBold HTML banner ads into my Air for Android app.

 

I'm having problems with launching the native browser when the banner is clicked. The link opens inside the stagewebview instance. I am using the sample provided by LeadBolt. I have followed the instructions set in the read me file. My app is still in TEST MODE. I have uploaded the html to my server, and changed all the necessary data. Also  when setting up the ad, open in new window is selected.

 

After dozens of testing with the code, I came to the conclusion that the  code below:

 

webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, loadAds);

 

is only fired once, and does not fire again when the ad is clicked, hence it loads the link inside the webview.

 

When I remove the: if(e.location != admobURL) statement, it loads the URL in a new window automatically as soon as the banner is displayed without a LocationChangeEvent.

 

Is it because the adMob URL is always the same in test mode hence if(e.location != admobURL) is not executed? It does not execute the code inside the above if statement or LocationChangeEvent is not fired when the banner is clicked , hence navigateToURL is not executed. I may be wrong but any solution will welcome. I am using Adobe Air for Android version 3.2

 

 

package  {

import flash.display.MovieClip;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.net.URLRequest;
import flash.events.LocationChangeEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;

public class LoadAds extends MovieClip {
private var admobURL:String;
private var webView:StageWebView;

public function LoadAds() {
// constructor code
//please change following string to your own url link, like
//"http://10.1.2.1/xxx/leadbolt.html"
admobURL = "My URL is here"; 

webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(0, 0, 480, 72);
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, loadAds);
webView.loadURL(admobURL);               
}

function loadAds(e:LocationChangeEvent):void {
if(e.location != admobURL){
e.preventDefault();
webView.historyBack();
var url:URLRequest = new URLRequest(e.location);
navigateToURL(url);
}

}
}     
}


Viewing all articles
Browse latest Browse all 2954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>