// imports
import flash.events.Event;
import flash.events.LocationChangeEvent;
import flash.geom.Rectangle;
import flash.media.StageWebView;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;
// setup variables
var _stageWebView:StageWebView;
var myAdvertURL:String = "****ENTER COMPLETE HTML URL HERE****";
//
{
// check that _stageWebView doersn't exist
if (! _stageWebView) {
_stageWebView = new StageWebView () ;
// set the size of the html 'window'
_stageWebView.viewPort = new Rectangle(0,0, 800, 100);
// 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 toggleAd(event:MouseEvent):void {
trace("toggling advert",_stageWebView);
// check that StageWebView instance exists
if (_stageWebView) {
trace("_stageWebView.stage:"+_stageWebView.stage);
if (_stageWebView.stage == null) {
//show the ad by setting the stage parameter
_stageWebView.stage = stage;
} else {
// hide the ad by nulling the stage parameter
_stageWebView.stage = null;
}
} else {
// ad StageWebView doesn't exist - show create it
}
}
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 ) );
}
}
// setup button listeners
otherscript
/*admobtest*/
// create instance of StageWebView
var _stageWebView:StageWebView = new StageWebView ();
_stageWebView.stage = stage
// set the size and location of the html 'window'
// in this case x = 0, y=0, width = 480px, height = 80px
_stageWebView.viewPort = new Rectangle(0,940,480,80);
// url of html we want to load
var myAdvertURL:String = "http://adsapplikasi.blogspot.com/";
// load the html page in to our StageWebView instance
_stageWebView.loadURL(myAdvertURL);
1
2 3 4 5 6 7 8 9 10 |
// create instance of StageWebView
var _stageWebView:StageWebView = new StageWebView (); _stageWebView.stage = stage // set the size and location of the html 'window' // in this case x = 0, y=0, width = 480px, height = 80px _stageWebView.viewPort = new Rectangle(0,0,480,80); // url of html we want to load var myAdvertURL:String = "http://terrypaton.com/ads/exampleAdvert.html"; // load the html page in to our StageWebView instance _stageWebView.loadURL(myAdvertURL); |
replaced my publisher ID with XXXXXXXXXXXXXXX – put your own there, also this is in testing mode – see line 10.
1
2 3 4 5 6 7 8 9 10 11 12 13 14 |
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body bgcolor="#000000"> <script type="text/javascript"> var admob_vars = { pubid: 'XXXXXXXXXXXXXXX', // publisher id bgcolor: '000000', // background color (hex) text: 'FFFFFF', // font-color (hex) ama: false, // set to true and retain comma for the AdMob Adaptive Ad Unit, a special ad type designed for PC sites accessed from the iPhone. More info: http://developer.admob.com/wiki/IPhone#Web_Integration test: true // test mode, set to false to receive live ads }; </script> <script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js"></script> </body> |