我正在將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