我正在将as2 swf加载到AIR应用程序中。它从文件加载时正常工作。但是从字节加载时,它在某种程度上打破(它反应到鼠标,但一些元素是无效)Loader.load和Loader.loadBytes的差异
var bytes:ByteArray = ... //loaded from resources
var loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext(false);
context.allowCodeImport = true; //this is neccessary
// Method 1 - blocks some scripts in loaded SWF
//context.applicationDomain = new ApplicationDomain();
// (application domain has no effect with as2 swf)
//context.securityDomain = SecurityDomain.currentDomain; //gives error 2114: securityDomain must be null
loader.loadBytes(bytes, context);
// Method 2 - loads properly
//loader.load(new URLRequest(file.url));
那么为什么不直接从文件加载它?我的资源受加密保护,我无法将它们转储到磁盘 - 它们仍然必须受到保护。
可能存在什么样的技巧从字节正确加载?
有similar question,但在我的情况下as2导致更多的问题。
感谢您的回答。我想知道为什么相同的AVM1代码在从文件加载时完全工作,并且从字节加载时部分中断。 – alxx 2010-11-19 17:53:54
我认为这是因为'load'方法将SWF视为一项资产,并且知道它将在AVM1实例中运行,而'loadBytes'方法会将AVM1字节码注入到导致问题的AVM2字节码中。 – gthmb 2010-11-19 18:08:43
也许这是对的(只有Adobe工程师可能确定)。无论如何,看起来这是错误。我很早以前通过重新制作AS2 SWF解决了这个问题(相同的功能以不同的方式完成),但没有找到直接的解决方案。 – alxx 2011-06-20 13:05:49