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?
Thanks!
- Jona
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,
Mihai
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.
Regards,
Mihai
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: https://market.android.com/details?id=air.GraffitiCityMarketFree&featu 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:
STEP I:
Get an Account: http://leadboltapps.com/web/publishers/signup.php?ref=10022842
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.
STEP III:
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" "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" />
<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;
}
</style>
</head>
<body>
****ENTER HTML AD CODE HERE****
</body>
</html>
STEP I:
Credit: I found this on another site and would like to give credit to the author of pixelpaton.com
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.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,onL ocationChange);
// 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
Hope this works and helps you. If you have questions, let me know. Enjoy.
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:
http://www.milkmangames.com/blog/2011/11/10/announcing-native-android- admob-support-for-adobe-air/
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!
Alex
Milkman Games
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
-scalling
-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 http://leadboltapps.com/web/publishers/signup.php?ref=10025809
(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 "http://ad.leadboltads.net/show_app_wall?section_id=...", 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="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="..." viewActivate="view1_viewActivateHandler(event)">
<fx:Script>
<![CDATA[
import flash.media.StageWebView;
import flash.net.URLRequest;
import spark.events.ViewNavigatorEvent;
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 );
webView.loadURL("http://ad.leadboltads.net/show_app_wall?section_id=...");
addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
}
else {
}
}
private function onLocationChanging( event:LocationChangeEvent ):void
{
event.preventDefault();
navigateToURL( new URLRequest( event.location ) );
}
protected function onRemove(event:ViewNavigatorEvent):void
{
this.webView.dispose();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:View>
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.
North America
Europe, Middle East and Africa
Asia Pacific