2
私はハードディスクから暗号化されたSWFを読み込み、このswfを復号化するAIRアプリケーションを使っています。その後、私は解読されたswfのbyteArrayを持っているので、Loaderまたは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で働いていました。 AIRの外部SWFファイルであるallowLoadBytesCodeExecution
のサンドボックスについてよく読んでいますが、この問題を解決することはできません。
byteArrayからswfファイルをロードするには?