守望者--AIR技术交流

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: ANE FlasCC 炼金术
查看: 2237|回复: 0
打印 上一主题 下一主题

[平台接入] 百度ane插件,百度移动广告联盟as3版本插件

[复制链接]
  • TA的每日心情
    擦汗
    2018-4-10 15:18
  • 签到天数: 447 天

    [LV.9]以坛为家II

    1742

    主题

    2094

    帖子

    13万

    积分

    超级版主

    Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

    威望
    562
    贡献
    29
    金币
    52903
    钢镚
    1422

    开源英雄守望者

    跳转到指定楼层
    楼主
    发表于 2014-12-30 14:23:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    相关链接:
    http://www.airmyth.com/forum.php?mod=viewthread&tid=28

    http://www.airmyth.com/forum.php?mod=viewthread&tid=29


    上一篇发布了百度广告
    ane使用教程,为了aser们方便在一个应用中同时使用百度和admob广告,特此再发布一个百度ane的插件。这个插件是adobe flash air ad network framework的一个扩展(https://code.google.com/p/adoble-flash-air-ad-network-framework/),
    只需要把代码保存为BaiduAdapter.as结合adobe air广告框架就可以非常方便的在一个air移动应用中添加admob广告和百度广告。百度ane下载地址:https://code.google.com/p/baidu-ane/




    1. package so.cuo.platform.ad.adapters
    2. {
    3.         import com.baidu.mobads.BaiDu;
    4.         import com.baidu.mobads.BaiDuAdEvent;
    5.         import com.baidu.mobads.BaiDuSize;
    6.         
    7.         import flash.events.Event;
    8.         import flash.events.EventDispatcher;
    9.         
    10.         import so.cuo.platform.ad.AdEvent;
    11.         import so.cuo.platform.ad.AdSize;
    12.         import so.cuo.platform.ad.IBanner;
    13.         import so.cuo.platform.ad.IInterstitial;

    14.         [Event(name="onBannerDismiss", type="so.cuo.platform.ad.AdEvent")]
    15.         [Event(name="onBannerFailedReceive", type="so.cuo.platform.ad.AdEvent")]
    16.         [Event(name="onBannerLeaveApplication", type="so.cuo.platform.ad.AdEvent")]
    17.         [Event(name="onBannerPresent", type="so.cuo.platform.ad.AdEvent")]
    18.         [Event(name="onBannerReceive", type="so.cuo.platform.ad.AdEvent")]
    19.         [Event(name="onInterstitialDismiss", type="so.cuo.platform.ad.AdEvent")]
    20.         [Event(name="onInterstitialFailedReceive", type="so.cuo.platform.ad.AdEvent")]
    21.         [Event(name="onInterstitialLeaveApplication", type="so.cuo.platform.ad.AdEvent")]
    22.         [Event(name="onInterstitialPresent", type="so.cuo.platform.ad.AdEvent")]
    23.         [Event(name="onInterstitialReceive", type="so.cuo.platform.ad.AdEvent")]
    24.         public class BaiduAdapter extends EventDispatcher implements  IBanner, IInterstitial
    25.         {
    26.                 protected static const banners:Vector.<AdSize>=new Vector.<AdSize>();
    27. //                protected var key:String;
    28.                 protected function get plat():BaiDu{
    29.                         return BaiDu.getInstance();
    30.                 }
    31.                 public function BaiduAdapter()
    32.                 {
    33.                         plat.addEventListener(BaiDuAdEvent.onBannerDismiss,onAdHandler);
    34.                         plat.addEventListener(BaiDuAdEvent.onBannerFailedReceive,onAdHandler);
    35.                         plat.addEventListener(BaiDuAdEvent.onBannerLeaveApplication,onAdHandler);
    36.                         plat.addEventListener(BaiDuAdEvent.onBannerPresent,onAdHandler);
    37.                         plat.addEventListener(BaiDuAdEvent.onBannerReceive,onAdHandler);
    38.                         
    39.                         plat.addEventListener(BaiDuAdEvent.onInterstitialDismiss,onAdHandler);
    40.                         plat.addEventListener(BaiDuAdEvent.onInterstitialFailedReceive,onAdHandler);
    41.                         plat.addEventListener(BaiDuAdEvent.onInterstitialLeaveApplication,onAdHandler);
    42.                         plat.addEventListener(BaiDuAdEvent.onInterstitialPresent,onAdHandler);
    43.                         plat.addEventListener(BaiDuAdEvent.onInterstitialReceive,onAdHandler);
    44.                         initBannerSize();
    45.                 }
    46.                 protected function initBannerSize():void
    47.                 {
    48.                         banners[AdSize.PHONE_PORTRAIT]=new AdSize(BaiDu.BANNER.width,BaiDu.BANNER.height);
    49.                         banners[AdSize.PHONE_LANDSCAPE]=new AdSize(BaiDu.IAB_BANNER.width,BaiDu.IAB_BANNER.height);
    50.                         banners[AdSize.PAD_PORTRAIT]=new AdSize(BaiDu.IAB_LEADERBOARD.width,BaiDu.IAB_LEADERBOARD.height);
    51.                         banners[AdSize.PAD_LANDSCAPE]=new AdSize(BaiDu.IAB_LEADERBOARD.width,BaiDu.IAB_LEADERBOARD.height);
    52.                         banners[AdSize.IAB_MRECT]=new AdSize(BaiDu.IAB_MRECT.width,BaiDu.IAB_MRECT.height);
    53.                 }
    54.                
    55.                 public function get supportDevice():Boolean
    56.                 {
    57.                         return plat.supportDevice;
    58.                 }
    59.                
    60.                 public function setTesting(deviceID:String=null):void
    61.                 {
    62.                 }
    63.                
    64.                 public function onAdHandler(e:Event):void
    65.                 {
    66.                         var ae:BaiDuAdEvent=e as BaiDuAdEvent;
    67.                         if(ae.data!=null&&(ae.data is BaiDuSize)){
    68.                                 var size:BaiDuSize=ae.data as  BaiDuSize;
    69.                                 this.dispatchEvent(new AdEvent(e.type,new AdSize(size.width,size.height)));
    70.                         }else{
    71.                                 this.dispatchEvent(new AdEvent(e.type,(e as BaiDuAdEvent).data));
    72.                         }
    73.                 }
    74.                
    75.                 public function dispose():void
    76.                 {
    77.                         plat.removeEventListener(BaiDuAdEvent.onBannerDismiss,onAdHandler);
    78.                         plat.removeEventListener(BaiDuAdEvent.onBannerFailedReceive,onAdHandler);
    79.                         plat.removeEventListener(BaiDuAdEvent.onBannerLeaveApplication,onAdHandler);
    80.                         plat.removeEventListener(BaiDuAdEvent.onBannerPresent,onAdHandler);
    81.                         plat.removeEventListener(BaiDuAdEvent.onBannerReceive,onAdHandler);
    82.                         
    83.                         plat.removeEventListener(BaiDuAdEvent.onInterstitialDismiss,onAdHandler);
    84.                         plat.removeEventListener(BaiDuAdEvent.onInterstitialFailedReceive,onAdHandler);
    85.                         plat.removeEventListener(BaiDuAdEvent.onInterstitialLeaveApplication,onAdHandler);
    86.                         plat.removeEventListener(BaiDuAdEvent.onInterstitialPresent,onAdHandler);
    87.                         plat.removeEventListener(BaiDuAdEvent.onInterstitialReceive,onAdHandler);
    88.                 }

    89.                 public function setInterstitialKeys(appID:String, key:String=null):void
    90.                 {
    91.                         plat.setKeys(appID,key);
    92.                 }

    93.                 public function cacheInterstitial():void
    94.                 {
    95.                         plat.cacheInterstitial();
    96.                 }

    97.                 public function showInterstitial():void
    98.                 {
    99.                         plat.showInterstitial();
    100.                 }

    101.                 public function isInterstitialReady():Boolean
    102.                 {
    103.                         return plat.isInterstitialReady();
    104.                 }

    105.                 public function get supportedInterstitial():Boolean
    106.                 {
    107.                         return true;
    108.                 }

    109.                 public function setBannerKeys(appID:String, key:String=null):void
    110.                 {
    111.                         plat.setKeys(appID,key);
    112.                 }

    113.                 public function showBanner(adSize:AdSize, position:int):void
    114.                 {
    115.                         plat.showBanner(new BaiDuSize(adSize.width,adSize.height),position);
    116.                 }

    117.                 public function showBannerAbsolute(adSize:AdSize, x:Number, y:Number):void
    118.                 {
    119.                         plat.showBannerAbsolute(new BaiDuSize(adSize.width,adSize.height),x,y);
    120.                 }

    121.                 public function hideBanner():void
    122.                 {
    123.                         plat.hideBanner();
    124.                 }

    125.                 public function getBannerSize(type:int):AdSize
    126.                 {
    127.                         if(type<banners.length&&type>=0){
    128.                                 return banners[type];
    129.                         }
    130.                         return new AdSize(BaiDu.BANNER.width,BaiDu.BANNER.height);
    131.                 }

    132.                 public function get supportedBanner():Boolean
    133.                 {
    134.                         return true;
    135.                 }
    136.         }
    137. }
    复制代码


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
    收藏收藏 分享分享 支持支持 反对反对 微信
    守望者AIR技术交流社区(www.airmyth.com)
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    
    关闭

    站长推荐上一条 /4 下一条

    QQ|手机版|Archiver|网站地图|小黑屋|守望者 ( 京ICP备14061876号

    GMT+8, 2026-1-24 22:49 , Processed in 0.082026 second(s), 32 queries .

    守望者AIR

    守望者AIR技术交流社区

    本站成立于 2014年12月31日

    快速回复 返回顶部 返回列表