problems with loading embedded swf files in air app

。_饼干妹妹 提交于 2020-01-13 06:53:27

问题


I have a game file which I create using flash cs 5.5. I have another swf file which is hint file which I embedded in that game file. It works fine in pc. I got problems when I tried to load that game file with embedded swf file. I got the following error: SecurityError: Error #3226: Cannot import a SWF file when LoaderContext.allowCodeImport is false. Can anyone tell me why is this happening ?


回答1:


I suppose you're working with adobe air for mobile on your android device. In air for mobile, there is extra restrictions on loading external SWF files - especially when they contain byte codes(ActionScript). Because your secondary SWF file is containing actionscript code for itself, you cannot load into your mobile air application without explicit security allowance.

AS3 uses Loader implicitly when you instantiate classes refering your embedded SWF files, and it loads with default option - which is set to different in air for mobile runtime environment.

You can load them with manual loading, by creating Loader and LoaderContext instance by yourself.

var ldr:Loader = new Loader();
var lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
lc.allowCodeImport = true;
ldr.load(new URLRequest("YOUR_FILE_PATH"), lc);

Also note that in iOS, even if allowCodeImport is set to true, you cannot load external SWF with codes, by any means.

For further details : http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/




回答2:


Try this kind of Context:

var loaderContext: LoaderContext = new LoaderContext();
loaderContext.allowLoadBytesCodeExecution = true; 
swfLoader.loaderContext = loaderContext;


来源:https://stackoverflow.com/questions/21398995/problems-with-loading-embedded-swf-files-in-air-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!