你好,游客 登录 注册 搜索
背景:
阅读新闻

Flash Web Game移植到Android平台需要注意的地方

[日期:2013-01-20] 来源:Linux社区  作者:linguifa [字体:大 中 小]

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,air不需要用new LoaderContext();

con = newLoaderContext(false,null,SecurityDomain.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>

linux
相关资讯       Android平台  Android移植 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款