Terhangat
Loading...

Adobe Flash CS6 : AdMob Controller for Android

Topik ini tidak membahas tentang cara memasang aplikasi apa pun, saya hanya ingin menunjukkan kepada Anda bagian lain dari Adobe AIR - Integrasi AdMob untuk Android, Jika Anda ingin melihat lebih banyak tentang hal lain, beri tahu saya di akhir topik ini.

[Prasyarat]
unduh dan instal dari instruksi mereka.

  1. Adobe Flash CS6
  2. http://www.adobe.com
  3. SDK Adobe AIR
  4. http://labs.adobe.com
  5. ANEAdMob
  6. https://github.com/pozirk/ANEAdMob

[Buat Aplikasi Adobe AIR]
1. Buka Adobe Flash dan pilih "AIR untuk Android"


2. Kemudian tekan "command + s", dan telusuri folder yang Anda inginkan untuk menyimpan proyek ini.
contoh: "FLAdmobControl.fla" lalu saya hanya menambahkan teks untuk pengujian saat aplikasi berjalan di layar Anda tidak membutuhkannya.


3. Pada panel "Publikasikan" klik ikon "pensil" lalu ketik nama "Utama" dan tombol keluar sebagai "Flash Professional" dan klik ok.


4. ActionScript telah dibuat seperti di bawah ini.


5. Tambahkan baris kode seperti gambar di bawah ini, pertama-tama Anda perlu mengimpor ekstensi admob ke kelas utama Anda yang telah Anda buat dan mouse event untuk mendeteksi sentuhan di layar.

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



6. Langkah selanjutnya, saya merekomendasikan untuk mendeklarasikan variabel pada kelas inisialisasi untuk akses di mana saja dari fungsi, dan tanda admob untuk menentukan menghidupkan / mematikan tampilan admob.

/---- 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. Selanjutnya terlalu lama tentang mengimplementasikan iklan baik spanduk dan interstisial, iklan perlu memanggil metode init () dan addeventlistener untuk mendeteksi peristiwa apa pun yang terjadi, ini semua yang Anda butuhkan cukup salin, terlalu mudah.

//---- 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.";
 }
}

//---- End-Script ----//



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

Sumber : https://gamedevtodied.blogspot.com/2016/04/adobe-flash-cs6-adobe-air-admob.html
HALAMAN SELANJUTNYA:

iklan banner

Previous
Next Post »
Thanks for your comment
close