歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Flash Web Game移植到Android平台需要注意的地方

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

日期:2017/3/1 10:02:49   编辑:Linux編程

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>

Copyright © Linux教程網 All Rights Reserved