Adobe Flash CS6 : AdMob Controller for Android
Test on:
- Mac OSX El Capitan
- Adobe Flash CS6 or above.
- Adobe AIR SDK 13 or above
- Asus Zenfone 4.5
- ANEAdMob Build3.6 : http://sh.st/U5NlH
[Sample source code]
Apk file:
Source code:
This topic not discuss about how to install any application, I just want to show you only apart of Adobe AIR - AdMob Integration for Android, If you want to see more on something else, please tell me at the end of this topic.
[Pre-Require]
download and install from any their instructions.
- Adobe Flash CS6
http://www.adobe.com
- Adobe AIR SDK
http://labs.adobe.com
- ANEAdMob
https://github.com/pozirk/ANEAdMob
[Create Adobe AIR Application]
1. Open Adobe Flash and choose "AIR for Android"
4. In "Publish" panel click an icon "pencil" then type name "Main" and leave button as "Flash Professional" and click ok.
7. Next step, i've recommended to declare variable on initialize class for access anywhere of function, and admob flag for determine turn on/off admob display.
//---- End-Script ----//
2. Add swc file by click on red-f icon and browse.. to ANEAdMob/air/AdMob/bin/AdMob.swc
3. Add ane by click add path [+] icon then click ane icon, after that browse.. to ANEAdMob/AdMob.ane
<android>
<manifestAdditions><![CDATA[<manifest><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><application>
<meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- should be android:value="@integer/google_play_services_version" --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application></manifest>]]></manifestAdditions>
</android>
and
<extensions>
<extensionID>com.pozirk.ads.AdMob</extensionID>
</extensions>
Sample image:
[Sample source code]
Apk file:
Source code:
It's work!! ;)
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob
Test on:
- Mac OSX El Capitan
- Adobe Flash CS6 or above.
- Adobe AIR SDK 13 or above
- Asus Zenfone 4.5
- ANEAdMob Build3.6 : http://sh.st/U5NlH
This topic not discuss about how to install any application, I just want to show you only apart of Adobe AIR - AdMob Integration for Android, If you want to see more on something else, please tell me at the end of this topic.
[Pre-Require]
download and install from any their instructions.
- Adobe Flash CS6
http://www.adobe.com
- Adobe AIR SDK
http://labs.adobe.com
- ANEAdMob
https://github.com/pozirk/ANEAdMob
[Create Adobe AIR Application]
1. Open Adobe Flash and choose "AIR for Android"

2. Then press "command + s", and browse to folder you want to save this project.
sample: "FLAdmobControl.fla" then I just add text for test when app running on screen you don't need it.
4. In "Publish" panel click an icon "pencil" then type name "Main" and leave button as "Flash Professional" and click ok.
5. An ActionScript was created as below.
6. Add line of code as below image, for first you need to import admob extension into your main class that's you were created and mouse event for detect touch on screen.
//---- Begin-Script ----//
// import Admob extension
import com.pozirk.ads.admob.AdMob;
import com.pozirk.ads.admob.AdParams;
import com.pozirk.ads.admob.AdEvent;
// mouse event as touchscreen event
import flash.events.MouseEvent;
//---- End-Script ----//
//---- Begin-Script ----//
// Dummy - AD UNIT ID for Banner test
private var _bannerAdUID:String = "ca-app-pub-3940256099942544/6300978111";
// Dummy - AD UNIT ID for Interstitial test
private var _intersAdUID:String = "ca-app-pub-3940256099942544/1033173712";
// Banner instance
protected var _banner:AdMob = new AdMob();
// Interstitial instance
protected var _inters:AdMob = new AdMob();
// check ads initialize
private var _initOK:Boolean = false;
private var _isShow:Boolean = false;
// check cache for Interstitial
private var _cacheOK:Boolean = false;
//---- End-Script ----//
8. Then we'll begin start the main code for starting point under main function, declare an access from button instance name binding to mouse event relate show and hide ads.
//---- Begin-Script ----//
btBanner.addEventListener(MouseEvent.CLICK, showBanner);
btInters.addEventListener(MouseEvent.CLICK, showInterstitial);
//---- End-Script ----//
9. Well next too long about implement ads both banner and interstitial, the ads need to call init() method and addeventlistener to detect any event happens, this is all you need just copy paste, too easy.
//---- Begin-Script ----//
_banner.init();
_banner.addEventListener(AdEvent.INIT_OK, onInitEvent);
_banner.addEventListener(AdEvent.INIT_FAIL, onEvent);
_banner.addEventListener(AdEvent.BANNER_SHOW_OK, onEvent);
_banner.addEventListener(AdEvent.BANNER_SHOW_FAIL, onEvent);
_banner.addEventListener(AdEvent.BANNER_LEFT_APP, onEvent);
_banner.addEventListener(AdEvent.BANNER_OPENED, onEvent);
_banner.addEventListener(AdEvent.BANNER_CLOSED, onEvent);
_inters.init();
_inters.addEventListener(AdEvent.INIT_OK, onInitEvent);
_inters.addEventListener(AdEvent.INIT_FAIL, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onCacheEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
_inters.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onCloseIntersEvent);
//cache interstitial ads here
_inters.cacheInterstitial(_intersAdUID);
//---- End-Script ----//
10. It's time to create new function from event listener need, when an error occurs or successful receive ads.
//---- Begin-Script ----//
// Any ads event focus on error detect
protected function onEvent(ae:AdEvent):void
{
trace(ae.type+" "+ae._data);
res.text = ae.type +" >> "+ ae._data;
}
// check ready for show
protected function onInitEvent(ae:AdEvent):void
{
_initOK = true;
}
// check ready received
protected function onCacheEvent(ae:AdEvent):void
{
_cacheOK = true;
}
// keep cache when closed
protected function onCloseIntersEvent(ae:AdEvent):void
{
_inters.cacheInterstitial(_intersAdUID);
}
//---- End-Script ----//
11. The last thing you need is function for show banner and interstitial by the way this is just simple case like a switch on/off to show and hide of banner but for interstitial just only show because it has own close button large enough for your finger to close it.
//---- Begin-Script ----//
private function showBanner(e:MouseEvent):void
{
//showing here
if(_initOK) {
if(!_isShow) {
_banner.show(_bannerAdUID, AdParams.SIZE_SMART_BANNER, AdParams.HALIGN_CENTER, AdParams.VALIGN_BOTTOM);
_isShow = true;
}else {
_banner.hide();
_isShow = false;
}
} else {
res.text = "Banner Not Ready.";
}
}
private function showInterstitial(e:MouseEvent):void
{
//showing interstitial ads here
if(_initOK && _cacheOK) {
_inters.showInterstitial();
} else {
res.text = "Inters Not Ready.";
}
}
12. This part is assign variable name to textfield for print out any message expect error and button for banner and interstitial.
Give a name in Properties as "res" for dynamic textfield, this textfield will print out any event detected.
Create simple two button type and give their name in Properties as "
btBanner" and "btInters", take a look on sample image.
[Add ANEAdMob]
1. Extract ANEAdMob.zip then in flash goto File > ActionScript Settings...
2. Add swc file by click on red-f icon and browse.. to ANEAdMob/air/AdMob/bin/AdMob.swc
3. Add ane by click add path [+] icon then click ane icon, after that browse.. to ANEAdMob/AdMob.ane
4. Click ok, now you already to setting application for publish.
[AIR Android Settings]
1. In flash goto File > AIR XX.X.X for Android Settings...
2. On General tab check any value as below. don't forget App ID not allow underscore (_) in name just remove it, Version label only for test you can leave it blank. You should see AdMob.ane in Included files.
3. Just skip Deployment and goto tab "Icons" add at least one icon size, i created my icon size 72x72 pixels for test.
4. Goto tab "Permissions" and check on "Manually manage permissions...descriptor file."
[Config Application-app.xml]
Open your "filename-app.xml" and paste this code after end of "</icon>" as below images and saved overwrite this files.<android>
<manifestAdditions><![CDATA[<manifest><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><application>
<meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- should be android:value="@integer/google_play_services_version" --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application></manifest>]]></manifestAdditions>
</android>
and
<extensions>
<extensionID>com.pozirk.ads.AdMob</extensionID>
</extensions>
Sample image:
[Publish to Android Device]
1. Goto tab "Deployment" and click "create" if you don't have filename.p12 file, fill any text field with your data, i'm just input sample data then click "Save as" to your project folder.
*If you found this error, please change "Type 1024-RSA" to "Type 2048-RSA", and save again.
2. After saved p12 file, fill in "Password" field and check setting as below image.
3. Connect your android device via usb cable. and click "Publish"
4. When your app has success installed on device, you should see this notice.
5. Let's see on your android device and don't forget to turn on your internet connection, AdMob banner was shows up on bottom of screen.
----------------------------->>
Learn more about ANEAdMob: https://github.com/pozirk/ANEAdMob































sorry I have a problem when running the file, it prints the compiler output me :
ReplyDelete"ArgumentError : Error # 3500 : The extension context does not Have a method With the name cacheInterstitial .
at flash.external :: ExtensionContext / _call ()
at flash.external :: ExtensionContext / call ()
at com.pozirk.ads.admob::AdMob/cacheInterstitial()[D:\Pozirk\_projects\ANEAdMob\air\AdMob\com\pozirk\ads\admob\AdMob.as:83]
at Main () [ / Users / Cristian / Downloads / FLCS6_Admob_Control / Main.as : 52 ]
at runtime :: ContentPlayer / loadInitialContent ()
at runtime :: ContentPlayer / playRawContent ()
at runtime :: ContentPlayer / playContent ()
at runtime :: AppRunner / run ()
at ADLAppEntry / run ()
at Global / runtime :: ADLEntry ()"
Can you tell me please because it does not work?
You can't run in flash ide, the extension not compatible on pc, you must publish/ exported as apk and test on android device only
Delete
DeleteAnd try but when running the install apk after the announcement was not loaded , stays on the screen without showing the ad, it can be? Any recommendation? Thank you very much for your time.
Pdta : I keep to the letter the tutorial but it does not work , the AIR SDK version I have installed 20
My sample source code use old ANE Admob and Adobe AIR 19, it's not compatible with AIR 20 or above. Why? because AIR 20 or above not support Android below 4.0.4
DeleteSo if you want to use my sample directly try to downgrade AIR to 19 by download AIR SDK 19 and install to Flash IDE and choose them.
when trying to install air sdk 19 , Animate adobe cc says you can not install a lower version of sdk 20 , some solution .
DeleteThank you very much for your valuable time
This comment has been removed by the author.
ReplyDeleteHey!! Thanks for your tutorial, simple and good explanation.
ReplyDeleteI just have a question, can you tell me please how can I show banner and interstitial without these buttons?
I mean banner still showed all time and Interstitial showed every 120s.
Thank you
If you want to show Banner after app launch immediately try this tutorial: http://gamedevtodied.blogspot.com/2015/05/adobe-flash-cs6-adobe-air-how-to.html
Deleteand for Interstitial without call button action try this: http://gamedevtodied.blogspot.com/2016/01/adobe-flash-cs6-adobe-air-how-to.html
For showing by schedule 120s for Interstitial you need to use Timer class try this: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f0f.html
then you can handling show / hide Interstitial when timer event callback.
Thank you!!
DeleteI added the timer to your code, and it works fine, every 120s an interstitial ad was displayed.
Now I've faced two problems: first the interstitial ads still displaying even the previous ads has not been closed, second if I minimize my app by pressing the Home button the ads still displayed.
I think I have to add these Events to my code,I have no idea how can I make this work:
stage.addEventListener(Event.ACTIVATE, Activate);
stage.addEventListener(Event.DEACTIVATE, Deactivate);
**//THE CODE//**
import com.pozirk.ads.admob.AdMob;
import com.pozirk.ads.admob.AdParams;
import com.pozirk.ads.admob.AdEvent;
import flash.utils.Timer;
import flash.events.Event;
stop();
var _admob: AdMob = new AdMob();
var AdmobTime: Timer = new Timer(120000, 0);
AdmobTime.addEventListener(TimerEvent.TIMER, ShowAdmob);
AdmobTime.start();
function ShowAdmob(evt: Event): void {
_admob.addEventListener(AdEvent.INIT_OK, onEvent);
_admob.addEventListener(AdEvent.INIT_FAIL, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onCacheOkEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onEvent);
_admob.init();
_admob.cacheInterstitial("ca-app-pub-3940256099942544/1033173712");
function onEvent(ae: AdEvent): void {
trace(ae.type + " " + ae._data);
}
function onCacheOkEvent(ae: AdEvent): void {
_admob.showInterstitial();
}
}
When you use "Timer", try this way it's safer.
Delete1. new Timer(1000, 120);
2. addEventListener(TimerEvent.TIMER_COMPLETE, completedEvent);
3. in function "completedEvent" insert "removeEventListener(TimerEvent.TIMER_COMPLETE, completedEvent);"
And badluck for interstitial cannot closed by any event, manual close via tap [X] on ads.
Thank you, your tutorial is work very well :) :) :*
ReplyDeleteYou're welcome. :)
Deletehi nice tutorial. i am new to this kind of stuff please help me out after creating this app should i have to go to admob site and search my app and place admob adds on my created app.
ReplyDeleteAs i known you must submit your app to googleplay store or appstore and wait a while for search your app. It's take a time, I'm not really sure how long before it's available for search and link to admob, try to check by yourself day by day.
DeleteOr you can manually add on create app but you need to make sure your info app correctly then after your app available on store it's will be automatically link to admob.
Hi Porawee: This is helpful indeed but have some clarifications...
ReplyDeleteYou're welcome :)
DeleteI'm finding this question from you but not seen it.
Delete################
Gamer Tommy has left a new comment on your post "Adobe Flash CS6 + Adobe AIR : AdMob Controller for...":
Hi Porawee thx for your reply ! I have installed the .apk file of urs ...in my mobile that has android 5.0. It working fine.. but when i have used your code it has the same error :
"ArgumentError : Error # 3500 : The extension context does not Have a method With the name cacheInterstitial .
at flash.external :: ExtensionContext / _call ()
at flash.external :: ExtensionContext / call ()
I have seen ur previous comment of urs that
" My sample source code use old ANE Admob and Adobe AIR 19, it's not compatible with AIR 20 or above. Why? because AIR 20 or above not support Android below 4.0.4
So if you want to use my sample directly try to downgrade AIR to 19 by download AIR SDK 19 and install to Flash IDE and choose them."
but i need this admob runs in my air 21 and android 5.0
but i have only adobe flash cs6 not CC.
I would be thank ful if giude me how to make it.
#################
I hope you can find out, if you want to use Adobe AIR 20 or Above and ANE Admob latest version you can try from https://github.com/pozirk/ANEAdMob ,he build with latest AIR version.
About your question "Why? because AIR 20 or above not support Android below 4.0.4"
Bcoz Adobe want to cut lost Android older version but they suggest we can build difference AIR version for support Android both newer and older version from Adobe Labs site
Hi Porawee !! Thx A lot.. :)..Let me try and tell u ..!!
DeleteHi Porawee, your tutorial is good for me. i learn much about banner and inerstitial air from here.
ReplyDeleteBut i Have one question when i do the last step (Publish) there is an error like this
"Error creating files.
Namespace is invalid in the application descriptor file"
Please help me, thanks a lot.
i think the error is from this step [Config Application-app.xml]
DeletePlease check this line first,
Deleteapplication xmlns="http://ns.adobe.com/air/application/3.9"
It's must be same version as your AIR SDK x.x.x
Second about ANE i'm use version 3.6 then you cannot use AIR 3.5 or below.
okay done i already change my version of sdk. now already published.
Deletebut why my ads not show when i click the button :(
First, try to use new dummy ads id from firebase, because google change dummy admob id to dummy firebase ads id. Then my dummy ads may not work.
DeleteSecond, if above method not work, you need to print debug event listener of ads listener to see what's happen.
okay thanks, i want ask once more to you .
Deleteif i have some frame, i want to location ads each frame when touch the button.
so each frame has button.
then i put the script of admob in same position(main.as)? just change the propertise of button. is that right?
Good question, i'm never test by once initialize and change position via each button, let's try. But i'm really sure you can change ads position via each button to re-initialize and then update position.
Deletehello can u make tutorial for Air 23.0 for Android.
ReplyDeletecoz this dont work for me..
Yes, sure. I've learn a lot from many people like you, anyone found any issue in difference case, so i've decided to "re-post for Admob + AIR 19.0" and "new post for Admob + AIR 20.0 and above" on next event (this week).
DeleteI'm apologize to you and everyone who try my solution and not success like tutorial, then i'll try and keep more fine step by step and hope will be work 100% next chance.
tnx man!
DeleteHere Bosna FX, https://gamedevtodied.blogspot.com/2017/01/adobe-flash-cc-2017-admob-control-for.html ,the new entry for Animate CC 2017 + AdMob Control, it's too long then i'm decide to separate into 3 parts.
Deleteooooohhhh thank u man!!
Deleteevery day i checking ur site :D
Deletei have this error
ReplyDeleteArgumentError: Error #3500: The extension context does not have a method with the name cacheInterstitial.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at com.pozirk.ads.admob::AdMob/cacheInterstitial()[D:\Pozirk\_projects\ANEAdMob\air\AdMob\com\pozirk\ads\admob\AdMob.as:83]
at Main()[C:\Users\Armin\Desktop\ANEAdMob-master\FLCS6_Admob_Control\Main.as:52]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
Hi,
DeleteI am getting this error while publishing,
Error: dx tool failed.could not create java virtual machine.
please anyone help.
You're welcome. :)
ReplyDelete