我正在使用AIR应用程序,它从硬盘加载加密的SWF并解密此swf。之后我有解密swf的byteArray,我想在Loader或SWFLoader中加载它。
private var file_byte:ByteArray;
private var myFileStream:FileStream;
private static var inputFile:File;
private var loader:Loader;
private function loadSWF(url:String):void
{
inputFile = new File(url);
myFileStream = new FileStream();
myFileStream.addEventListener(Event.COMPLETE, completed);
myFileStream.openAsync(inputFile, FileMode.READ);
file_byte = new ByteArray();
}
private function completed(event:Event):void
{
myFileStream.readBytes(file_byte, 0, myFileStream.bytesAvailable);
//Decrypting file
file_byte = decrypt(file_byte);
// Prepare the loader context to avoid security error
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.allowLoadBytesCodeExecution = true;
loaderContext.allowCodeImport = true;
// Load the SWF file
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete);
loader.loadBytes(file_byte,loaderContext);
}
private function onChildComplete(e : Event) : void
{
this.addChild(loader);
}
安全错误:
Error #3207: Application-sandbox content cannot access this feature.
at flash.system::Security$/allowDomain()
at rfx::MainTimeline_cbc00d6d7b3a063d505c336e0c8f32a1()[constructor.as:0]
byteArray
是正确的,我将他写入光盘中的文件并且他在Flash Player中工作得很好。我在AIR中阅读了很多关于sandbox,allowLoadBytesCodeExecution
,外部SWF文件但我无法解决这个问题!
如何从byteArray加载swf文件?
答案 0 :(得分:2)
我可能有点晚了但是我在寻找自己的问题时偶然发现了这一点。请尝试用此替换构造函数调用。
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);