我正在尝试使用Code Alchemy @ https://github.com/lancelot1/ane-admob提供的ANE实现应用内横幅,但每次都会出错。我究竟做错了什么?我已经链接了ANE,启用了链接包并修改了主app.xml。
我收到错误(错误1120:访问未定义的属性adMobManager):
if(adMobManager.isSupported)
{
adMobManager.verbose = true;
adMobManager.operationMode = AdMobManager.PROD_MODE;
adMobManager.bannersAdMobId = "ca-app-pub-5756871557297373/2682945046";
adMobManager.interstitialAdMobId = "ca-app-pub-5756871557297373/4159678246";
adMobManager.createBannerAbsolute(AdMobSize.BANNER,AdMobPosition.BOTTOM_CENTER,"BottomBanner1", null, true);
adMobManager.showBanner("BottomBanner1");
adMobManager.createInterstitial(null,true);
adMobManager.showInterstitial();
}
和错误(1120:访问未定义的属性调度程序):
if (!dispatcher.hasEventListener(AdMobEvent.BANNER_LOADED))
dispatcher.addEventListener(AdMobEvent.BANNER_LOADED, onBannerLoaded);
完整代码:
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160">
<s:ViewNavigator label="MAPA" width="100%" height="100%" firstView="views.MAPAView"/>
<s:ViewNavigator label="LISTA" width="100%" height="100%" firstView="views.LISTAView"/>
<s:ViewNavigator label="SOBRE" width="100%" height="100%" firstView="views.SOBREView"/>
<fx:Style source="QRApp.css"/>
<fx:Script>
<![CDATA[
import com.codealchemy.ane.admobane.*;
import com.codealchemy.ane.admobane.AdMobManager;
var adMobManager:AdMobManager = AdMobManager.manager;
var num:int = adMobManager.bannersQuantity;
var bannerIds:Array = adMobManager.bannersNames;
var device:String = adMobManager.device;
var state:Boolean = adMobManager.isInterstitialLoaded();
if(adMobManager.isSupported)
{
adMobManager.verbose = true;
adMobManager.operationMode = AdMobManager.PROD_MODE;
adMobManager.bannersAdMobId = "ca-app-pub-5756871557297373/2682945046";
adMobManager.interstitialAdMobId = "ca-app-pub-5756871557297373/4159678246";
adMobManager.createBannerAbsolute(AdMobSize.BANNER,AdMobPosition.BOTTOM_CENTER,"BottomBanner1", null, true);
adMobManager.showBanner("BottomBanner1");
adMobManager.createInterstitial(null,true);
adMobManager.showInterstitial();
}
/**
* Extension event dispatcher instance
**/
private function get dispatcher():EventDispatcher
{
// Return the extension dispatcher
return adMobManager.dispatcher;
}
if (!dispatcher.hasEventListener(AdMobEvent.BANNER_LOADED))
dispatcher.addEventListener(AdMobEvent.BANNER_LOADED, onBannerLoaded);
/**
* onBannerLoaded Event listener
*
* @param e AdMobEvent Object
**/
static private function onBannerLoaded(e:AdMobEvent):void
{
// Do Something like show the banner...
adMobManager.showAllBanner();
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<fx:Style source="QRApp.css"/>
答案 0 :(得分:0)
我不知道你是否还有这个问题
但是,如果在Application.xml中未正确声明扩展名,则会出现错误消息“错误1120:访问未定义属性adMobManager”。
请确保扩展已完全声明。
[2014年8月28日新增]
我提供了一个完整的演示应用程序,用于查看和测试Flash Builder 4.7和Flash Develop的设置
您可以在此处找到示例源代码:
- https://github.com/lancelot1/ane-admob
我相信这个项目应该回答有关如何在Flash Builder 4.7和Flashdevelop中集成AdMob Ane Extension的任何问题。
我希望这可以帮助任何有同样问题的人。