• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Admob - Google Ads?

New Here ,
Oct 31, 2010 Oct 31, 2010

Copy link to clipboard

Copied

Innovative - will you? where can I find flash/air integration admob android ...

...where is Google Ads - Admob plugin or similar code?

This is a must in next release Flash CS5.5/AIR2.5!

this is very important ...

TOPICS
Development

Views

147.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
replies 104 Replies 104
Mentor ,
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

Has anyone tried using a StageWebView object and the JavaScript provided by Admob here: http://developer.admob.com/wiki/Android ?

Or constructing a URL request using the information here http://developer.admob.com/wiki/Requests ?

I haven't had a chance to try it yet -- just wondering if anyone had already gone down that path.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

I was going down this path; but It doesn't run:

Error #1014: Class flash.media::StageWebView could not be found.

the import is fine in the IDE; it compiles also.
So I have to figure out why it's not working; but it looks like a nice option to build a view and connect to the ad-site of you choice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

Possibly you need to compile to a later SWF version or update the namespace of the application descriptor to 2.5. For the SWF version in Flash Builder, add -target-player 10.1 to the compile options. However, if you are targeting the iPhone, note that the StageWebView class was added in AIR 2.5 and isn't available on iOS yet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

Anyone know how to hide the scrollbars? Here's what I wrote and it works for loading a page from my site. I still haven't implemented it for using admob. I'm new to admob so first was getting it to display. Can I set up a hidden page on my url and load it in?

import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
var webView:StageWebView = new StageWebView();

function StageWebViewExample()
{
    webView.stage = this.stage;
    //webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
    webView.viewPort = new Rectangle(0,0,stage.stageWidth,50);
    webView.loadURL( "http://www.bluetoastmedia.com" );
}
StageWebViewExample();
//------------------------

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

Actually, once I run it as an app, the viewport takes over the entire screen regardless...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I´ve manage to pull and successfully register the impressions and clicks using the StageWebView, in an air4android app, but I can’t get rid of the scroll bars and zoom buttons.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I get no ads using this javascript in my html page... I however have the scrollbars gone. Anyone?

<script type="text/javascript">
var admob_vars = {
pubid: 'a14d430b52xxxxx', // publisher id
bgcolor: '000000', // background color (hex)
text: 'FFFFFF', // font-color (hex)
ama: true, // 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: false // test mode, set to false to receive live ads
};
</script>
<script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js"></script>

Any idea why no ads show up even in the browser on my Android? Requests show to be coming in. I even made a house ad to see if it would serve... nuthin.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I'm using smaato and the provided php code, and its working.

haven't tried with admob yet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

This code isn't working for me either.  I can't even to display an ad when I'm using the browser on my laptop...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I don’t really know why, but this only works if the app is running on the mobile device,

on the laptop I can’t see anything either.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I couldn't get it to work using the first example provided by adMob, either. What did work was to use the "manual" mode and call the fetchAd() method in the adMob Javascript code directly.

This is the HTML file that I loaded into my StageWebView object:

NOTE: change the publisher ID to your own -- or I will get credit for your ads!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
var admob_vars = {
  pubid: 'a14d4115a7779ac', // publisher id
  bgcolor: 'ffffff', // background color (hex)
  text: '000000', // font-color (hex)
  test: false, // test mode, set to false if non-test mode
  manual_mode: true

};

function showAd()
{
     //alert("show ad");
    _admob.fetchAd(document.getElementById('adspace'));

}
</script>
<script type="text/javascript" src="http://mm.admob.com/static/iphone/iadmob.js"></script>
<style type="text/css">
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
</style>
</head>

<body onload="showAd()">
<div id="adspace">

</div>
</body>
</html>

And this is the ActionScript code (I did this using Flash CS on the main timeline, if you are doing this in Flash Builder or in a class, you will have to adapt it accordingly):

//Admob
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
var adViewPort = new Rectangle( 0, 0, this.stage.stageWidth, 60 );
webView.viewPort = adViewPort;

webView.addEventListener(ErrorEvent.ERROR, onWebViewError );
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING, onWebViewLocChanging );
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onWebViewLocChange );

var templateFile:File = File.applicationDirectory.resolvePath( "adview.html" );
var workingFile:File = File.createTempFile();
templateFile.copyTo( workingFile, true );
var fstream:FileStream = new FileStream();
fstream.open( templateFile, FileMode.READ );
var htmlString:String = fstream.readUTFBytes( fstream.bytesAvailable );

try
{
    //webView.loadString( htmlString );
    webView.loadURL( workingFile.url );
}
catch (e:Error)
{
    trace( e );
}

function onWebViewLocChange( event:LocationChangeEvent ):void
{
    trace( "--------------- Change to" + event.location );
    if( event.location != workingFile.url )
    {   
        trace("----------- reset ad URL ----------");
        navigateToURL( new URLRequest( event.location ) );
        try
        {
            //webView.loadString( htmlString );
            webView.loadURL( workingFile.url );
        }
        catch (e:Error)
        {
            trace( e );
        }
    }
}

function onWebViewLocChanging( event:LocationChangeEvent ):void
{
    trace( "--------------- Changing " + event.location );
    event.preventDefault();
    navigateToURL( new URLRequest( event.location ) );
}

function onWebViewError( error:ErrorEvent ):void
{
    trace( error );
}

One issue I noticed is that the method shown above in AS won't work when you are running on the app through ADL (or Test Movie in Flash CS, etc). You can use the loadString() method, which is commented out. The reason for this is that the StageWebView control is implemented in different ways on different OS's. AIR only controls the desktop control, the other OS's use the OS supplied code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

It works on the desktop for me in a FlashDevelop Android/AIR template. No luck in the "regular" AIR FlashDevelop or in Flex. So I don't know at the moment what exactly is the "magic setting". But I'am happy with the progress

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

Well here is my code stored on my URL

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

</head>
<body bgcolor="#000000">
<script type="text/javascript">
var admob_vars = {
pubid: 'my_id', // 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: false // 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>
</html>

Here is my AS3:

import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
var webView:StageWebView = new StageWebView();

function StageWebViewExample()
{
    webView.stage = this.stage;
    //webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
    webView.viewPort = new Rectangle(0,0,800,85);
    webView.loadURL( "myURL/page.html" );
   
}
StageWebViewExample();

----------------------------------------

Now I need to figure out how to make the viewPort redraw when the ad is clicked...

Any suggestions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I think I have it:

//My code:

function StageWebViewExample()
{
    webView.stage = this.stage;
    //webView.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
    webView.viewPort = new Rectangle(0,395,800,85);
    webView.loadURL( "http://www.bluetoastmedia.com/admob/charlies_rocket.html" );
    webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,getUpdate);
}
StageWebViewExample();
//resize;
function getUpdate(event:LocationChangeEvent):void
{
    if (webView.location != "http://www.myadpage.html")
    {
        //handle resize here:
        webView.viewPort = new Rectangle(0,0,800,480);
    }

}

//so far it works. It resizes the viewport if the ad is clicked and loads a full screen of the url.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

one minor issue.

I cannot open the market from an ad. I can open urls but not the market. Hmmmm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

And here is the answer to that one. Forget resizing the viewport. This launches the native browser

function getUpdate(event:LocationChangeEvent):void
{
    if (webView.location != "my_ad_URLpage")
    {
        //handle resize here:
        //webView.viewPort = new Rectangle(0,0,800,480);
        event.preventDefault();
        navigateToURL( new URLRequest( event.location ) );

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

Note that the locationChange event can't be prevented -- only the locationChanging event. And for some reason, locationChanging events are not dispatched when you click on an ad.

I suspect your code works because navigating to a market: URL doesn't work in the StageWebView, it only works with navigateToURL(). If you clicked on an ad with a http: destination, the StageWebView would navigate. The workaround I came up with is to launch the system browser in response to the locationChange() event (as you do), but since I can't prevent the default, I just reload my ad page. (This is demonstrated in the code I posted earlier).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2011 Jan 27, 2011

Copy link to clipboard

Copied

I have it working with a straight image but not a page yet.

Sent via Android.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

Has anyone tried using the Flash Lite code that Admod provides?  The classes are in ActionScript.  I'm still learning ActionScript, so I'm not sure if I can get this working...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2011 Jan 28, 2011

Copy link to clipboard

Copied

I have it working with Admob now. I think there was a time

period that I had to wait for the server to update? I don't know but it works now. I manually added the d

imensions of the webview object to make the scrollbars go away. I can't believe it!


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

Hey guys,

I'm trying to setup an admob account, but couldn't get any ads to display. Do I need a wap site for this, or can I use my regular server?

I copied the code posted here by someone, and when I tried it in my browser, all I got was just an empty page...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

heya!

make sure there's ads available for your "location", I only got a banner once from my location (sweden)

I do more often get more ads when rendering my page @ http://ipinfo.info/netrenderer/index.php (germany)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 04, 2011 Feb 04, 2011

Copy link to clipboard

Copied

Ive got ads loading into air apps. You can click on them but it throws a sandbox error. Maybe some one else  can help. Code is real simple and derived from the flash lite sdk.

Remember to update your site ID. Below are URL's to regular and test ads. The only differences is the additions of 'm=true' to enable test mode. Download the flash lite sdk if you would like to decode the URL or use other options not included here.

** Ad URL **

var remoteSwfUrl:String =
                    "http://r.admob.com/ad_source.php?f=swf&client_sdk=1&s=<SITE_ID>&u=Adobe%20Device%20Central&screen_width=480&screen_height=816&so=normalp&v=20100322-FlashLite-23e06b5ca61845dc&pub_data[fl_gif]=0&pub_data[fl_jpg]=0&pub_data[fl_png]=1&pub_data[flash_lite_version]=FlashLiteVersion";

** Test Ad URL **

var TestUrl:String =
                    "http://r.admob.com/ad_source.php?f=swf&client_sdk=1&s=<SITE_ID>&m=true&u=Adobe%20Device%20Central&screen_width=480&screen_height=816&so=normalp&v=20100322-FlashLite-23e06b5ca61845dc&pub_data[fl_gif]=0&pub_data[fl_jpg]=0&pub_data[fl_png]=1&pub_data[flash_lite_version]=FlashLiteVersion";

Ad.load(remoteSwfUrl);

<mx:SWFLoader id="Ad" />

It appears that one of the biggest problems is the loaded SWF(Ad) is an older version, Avm movie 1 (or something). If this were updated to an actions scrip 3 - avm move 2, then retrieving variables from the swf (including the link url) would be possible/easier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

Does Adobe even track these forums?

Adobe needs to throw some weight over at Admob and get them to release an official API for A4A (Air 4 Android).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 30, 2011 Jan 30, 2011

Copy link to clipboard

Copied

I agree. I love as3. It is a beautiful language. But I keep looking into Unity/Java(Script) etc... just because of the Ad api's.

To me a perfect Ad integration would be the killer-flash apl. Maybe it's not Adobe's core business; but they even have the

power to become the default ad-broker for flash apps.

just my 2cts

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines