2
我与它加载从硬盘加密的SWF和解密这个SWF的AIR应用程序的工作。之后,我有解密的SWF的byteArray,我想在加载器或SWFLoader中加载它。如何从byteArray加载swf文件?
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中运行良好。我阅读了很多关于沙箱,allowLoadBytesCodeExecution
,AIR中的外部SWF文件,但我无法解决这个问题!
如何从ByteArray中加载swf文件?