Skip navigation
Currently Being Moderated

Showing ADs on AIR apps for iOS and Android?

May 25, 2011 12:11 PM

I'm currently debating if I should go ahead with game development on AIR.  I know the game will be fast and snappy since it's a very simple game.  My main concerns are;


1. Will I be able to display ADs inside the game?

2. Will these ADs be allowed by Apple?

3. What companies are available for ADs?



- Jona

  • Currently Being Moderated
    May 31, 2011 11:37 AM   in reply to medicalsounds

    Ideally you'd want to ask this question in the "Mobile Development" section (1 section deeper).

    Mark as:
  • Currently Being Moderated
    Jun 2, 2011 4:45 AM   in reply to medicalsounds

    Hi Jona,

    It is indeed possible to display ads in mobile AIR applications. There should be at least two ways of doing this: either by using some ActionScript wrapper (if your ad network offers such a wrapper) or by using the StageWebView class. Here's two links that should get you started: Displaying HTML content in mobile apps and a blog post on the same topic.


    Hope this helps,


    Mark as:
  • Currently Being Moderated
    Jun 2, 2011 4:48 AM   in reply to medicalsounds

    As for the other two questions:


    2. I don't know what Apple's rules are for displaying ads in applications. I suppose their developer license agreement would cover that specific topic

    3. There are a couple of ad providers that offer the option to display ads on mobiles. AdMob is one such ad provider, but there should be others. A simple Google search should yield at least a couple relevant results.




    Mark as:
  • Currently Being Moderated
    Aug 22, 2011 9:14 PM   in reply to medicalsounds

    After a lot of trouble (account canned on ADMOB ) and research, I have gotten Ads to work in all my Android Apps. This will work on a lot of AD networks, but most will ban you click fraud. Only one network allows this method and they provide support for it too.


    I have over 100 games apps. with this method implemented and working. Here is a link to one of them for you to see how it will look in game. I am using multiple ads in this to force the user to click and make me some money: re=search_result


    Does LeadBolt offer HTML integration for banner ads?

    LeadBolt does allow banner ads to be integrated into your app using HTML, rather than using our SDK. To create a HTML banner ad after adding an app to the LeadBolt portal, simply click “Add Ad” and select “App Banner (HTML)” from the drop down box. The HTML snippet can then be added directly into your app’s HTML framework.

    So far my eCPM is $6.15


    I have created this guide to show my appreciation:


    Publisher Code:


    STEP I:

    Get an Account:

    STEP II:

    Click on the “APPS” tab and “Create New APP” to create an AD. Remember to change content unlocker to HTML Banner. While in the process.


    Get the HTML AD Code and keep it safe. That is all we need from the site. How simple was that?




    Create an HTML File and Load it to your site. Remember to replace your HTML Code from above step with where I have put: ****ENTER HTML AD CODE HERE****


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="">


    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

    <title>Untitled Document</title>

    <style type="text/css">

    body,td,th {

         color: #FFF;


    body {

         background-color: #000;

         margin-left: 0px;

         margin-top: 0px;

         margin-right: 0px;

         margin-bottom: 0px;

         text-align: center;

         position: relative;











    Action Script Code:


    STEP I:

    Credit: I found this on another site and would like to give credit to the author of

    The only change you need to make is to enter your website html url where you have placed the AD HTML FILE in the space where I have put : "****ENTER COMPLETE HTML URL HERE****". Where ever you want the AD, place the following code:


    // imports



    import flash.geom.Rectangle;






    // 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,onL ocationChange);

                                    // start loading the URL;



                    // 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) {


                                    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


                                    // Launch a normal browser window with the captured  URL;

                                    navigateToURL( new URLRequest( event.location ) );



    // setup button listeners



    Hope this works and helps you. If you have questions, let me know. Enjoy.

    Mark as:
  • Currently Being Moderated
    Nov 14, 2011 12:27 PM   in reply to medicalsounds

    Hey  guys,


    I thought you might be interested to know our Native AdMob AIR 3 Extension for Android just came out.  You can check it out here:



    This is a true native java/android extension, not a hack with StageWebView.  It supports creating, destroying, showing and hiding of ads, all the AdMob sizes and formats for phones and tablets, events dispatched for all lifecycle states, etc.  It also smartly handles any changes to stage orientation, and has included sample apps.  You can get your ads inserted with 2 lines of code.


    You can also see it in action with our game Aqualux here.

    Hope it's useful!  I'll be releasing a similar versin for iOS, and a GameCenter extension and some other goodies very soon!



    Milkman Games

    Mark as:
  • Currently Being Moderated
    Nov 23, 2011 10:01 PM   in reply to medicalsounds

    Thanks for the informaton!

    Mark as:
  • Chriszzzzzzzzzzzz
    18 posts
    Jul 7, 2011
    Currently Being Moderated
    Feb 19, 2012 5:41 AM   in reply to Michael MH Ng

    Leadbolt have just introduced a new method of displaying ads for mobile apps called app wall. Instead of banners other android apps are advertised. This is very simple and eliminates many problems with banners like;

    -different banner sizes

    -no ads to display

    -screen orientation


    -hosting a HTML file

    -account banned

    One simple line of code inserted into a stagewebview will display a standard size ad for an app, which can be clicked on, taking you straight to the app in the marketplace.

    If you decide to use this code and sign up to Leadbolt please use this referral code

    (you will still earn 100% of revenue).



    1. To start sign up to Leadbolt as a pubisher using the above link. Go to apps and create a new app using app wall (HTML), Then click the get code, which will look like this "", then simply add this to the stagewebview on any mxml view you want the add to show.


    2.mxml example


    <?xml version="1.0" encoding="utf-8"?>

    <s:View xmlns:fx=""

            xmlns:s="library://" title="..." viewActivate="view1_viewActivateHandler(event)">









                protected var webView:StageWebView = new StageWebView();

                protected var openBrowser:Boolean = true;



                protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void


                    if (StageWebView.isSupported)


                        webView.stage = stage;

                        webView.viewPort = new Rectangle(0, stage.height - 160, stage.stageWidth, 160);

                        webView.addEventListener( LocationChangeEvent.LOCATION_CHANGING, onLocationChanging );    




                    else {




                private function onLocationChanging( event:LocationChangeEvent ):void



                    navigateToURL( new URLRequest( event.location ) );



                 protected function onRemove(event:ViewNavigatorEvent):void









            <!-- Place non-visual elements (e.g., services, value objects) here -->





    3. This code can be modified to work with flash


    4. If you want to see this in action feel free to download 'Arsenal Player Stats' for android and click on charts.

    Mark as:
  • Currently Being Moderated
    Mar 13, 2012 2:06 AM   in reply to Chriszzzzzzzzzzzz

    Can we have a Flash version of this ?



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points