On iPhone the ad is displayed in the html container and when you click the ad the web browser opens up with the correct site of the ad. But on Android there’s only a “Web page not available” with the green Android dude looking down from above, instead of the ad which should be there instead. I’ve set the internet permission and other tests shows internet does work, but this code doesn’t for some reason, only on iPhone. If I remove the internet permission, the html container is just white and empty.
html:
<!doctype html>
<html>
<head>
<script type=“text/javascript” src=“http://ad.leadbolt.net/show_app_ad.js?section_id=xxxxxxxxx”></script>
<meta name=“viewport” content=“width=device-width, height=device-height, user-scalable=no”/>
</head>
<body>
</body>
</html>
AS code:
var _stageWebView:StageWebView;
var myAdvertURL:String=“http://www.blahblah.com/blah.html”;
// check that _stageWebView doersn’t exist
if (! _stageWebView) {
_stageWebView = new StageWebView () ;
// set the size of the html ‘window’
_stageWebView.viewPort=new Rectangle(0,215,320,50);
// add a listener for when the content of the StageWebView changes
_stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onLocationChange);
// start loading the URL;
_stageWebView.loadURL(myAdvertURL);
}
// show the ad by setting it’s stage property;
_stageWebView.stage=stage;
function destroyAd(event:MouseEvent):void {
// check that the instace of StageWebView exists
if (_stageWebView) {
trace(“removing advert”);
// destroys the ad
_stageWebView.stage=null;
_stageWebView=null;
}
}
function onLocationChange(event:LocationChangeEvent):void {
// check that it’s not our ad URL loading
if (_stageWebView.location!=myAdvertURL) {
// destroy the ad as the user has kindly clicked on my ad
destroyAd(null);
// Launch a normal browser window with the captured URL;
navigateToURL( new URLRequest( event.location ) );
}
}