Flash web game移植到android平台需要注意的地方

19 篇文章 0 订阅
5 篇文章 0 订阅

1、air不支持Security.allowDomain("*");

如同一个swf即要支持flash player播放,又要支持air,则通过类型来判断:

if(flash.system.Capabilities.playerType !="Desktop")
         Security.allowDomain("*");


 2、var cm:ContextMenu =new ContextMenu();

air的 cm.customItems为空。


 3、报错:调用loader.loadBytes()方法时,SecurityError:Error #3226: Cannot import a SWF file when LoaderContext.allowCodeImport isfalse.

原因是没有设置LoaderContext.allowCodeImport,这样解决:

var con:LoaderContext = newLoaderContext();
con.allowCodeImport = true;
loadBytes(mc, con);


4、报错:1119: 访问可能未定义的属性allowCodeImport (通过 static 类型 flash.system:LoaderContext 引用)。

原因是使用了allowCodeImport属性,需要flash player 10.1才支持

  

5、报错:调用loader.load()方法时,SecurityError:Error #2142: Security sandbox violation: local SWF files cannot use theLoaderContext.securityDomain property.

原因是LoaderContext使用了SecurityDomain.currentDomain,air不支持SecurityDomain.currentDomain ,但依旧可以使用new LoaderContext();

con = new LoaderContext(false,null,SecurityDomain.currentDomain);----不支持
con = new LoaderContext(false,ApplicationDomain.currentDomain);----支持
loader.load(new URLRequest(_source), con);

 

6、旋转实现

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE,onOrientationChange);
private functiononOrientationChange(event:StageOrientationEvent):void
                 {
                            switch(event.afterOrientation)
                            {
                                     caseStageOrientation.DEFAULT: // re-orient display objects based on // the default(right-side up) orientation.
                                               stage.setOrientation(StageOrientation.DEFAULT)
                                               break;
                                     caseStageOrientation.ROTATED_RIGHT: // Re-orient display objects based on //right-hand orientation.
                                               stage.setOrientation(StageOrientation.ROTATED_RIGHT)
                                               break;
                                     caseStageOrientation.ROTATED_LEFT: // Re-orient display objects based on //left-hand orientation.
                                               stage.setOrientation(StageOrientation.ROTATED_LEFT)
                                               break;
                                     caseStageOrientation.UPSIDE_DOWN: // Re-orient display objects based on // upside-downorientation.
                                               stage.setOrientation(StageOrientation.UPSIDE_DOWN)
                                               break;
                            }
                 }

 

7、到目前为止,好像还不能实现手机麦克风(Microphone.isSupported为true,但不知为何说话没反应,待解决)

 

8、自定义air应用图标:修改-app.xml文件,icon属性

<icon>
                   <image16x16>ico/16.png</image16x16>
                   <image32x32></image32x32>
                   <image36x36></image36x36>
                   <image48x48></image48x48>
</icon>



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星星之Coder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值