I'm working with the AIR application which loads the encrypted SWF from hard disc and decrypt this swf. After that I have byteArray of decrypted swf and I want to load it in Loader or 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);
}
Security Error:
Error #3207: Application-sandbox content cannot access this feature.
at flash.system::Security$/allowDomain()
at rfx::MainTimeline_cbc00d6d7b3a063d505c336e0c8f32a1()[constructor.as:0]
byteArray
is correct, I wrote him to the file in the disc and he worked in the Flash Player well. I read a lot of about sandbox, allowLoadBytesCodeExecution
, external SWF files in AIR but I can't to solve this problem!
How to load swf file from byteArray?