在AIR安全沙箱中执行远程SWF

| 我尝试下载一个外部SWF并在AIR安全沙箱中运行它。 这是AIR应用程序的代码:
public class Downloader extends Sprite
{

    private static const REMOTE_FILE:URLRequest = new URLRequest(\"http://myserver.com/downloadable.swf\");
    private var _main:NativeWindow;

    public function Downloader()
    {
        var loader:URLLoader = new URLLoader(REMOTE_FILE);
        loader.dataFormat = URLLoaderDataFormat.BINARY;
        loader.addEventListener(Event.COMPLETE, downloadComplete);
    }

    private function downloadComplete(e:Event):void{
        var ba:ByteArray = e.target.data;
        var stream:FileStream = new FileStream();
        var file:File = File.applicationStorageDirectory.resolvePath(\"downloadable.swf\");
        stream.open(file, FileMode.WRITE);
        stream.writeBytes(ba);
        stream.close();

        loadAndRunSwf();
    }

    private function loadAndRunSwf(){       
        this._main = new NativeWindow();
        this._main.width = 1024;
        this._main.height = 768;

                    ////obsolete?
        //var context:LoaderContext = new LoaderContext();
        //context.allowLoadBytesCodeExecution = true;
        //context.applicationDomain = ApplicationDomain.currentDomain;  

        var file:File = File.applicationStorageDirectory.resolvePath(\"downloadable.swf\");
        var loader:Loader = new Loader();
        loader.load(new URLRequest(file.url)/*,context*/);

        this._main.stage.addChild(loader);
        this._main.activate();
    }
}
downloadable.swf的代码:
public class Downloadable extends Sprite
{
    private var _btn:Button = new Button();
    private var _baseFolder:File = new File(\"app-storage:/\");

    public function downloadable_test()
    {
        this.addChild(_btn);
        _btn.label = \"access Harddisk\";
                    ...
    }
}
所以现在,如果我运行Downloader,它将下载swf并尝试运行它,但是我将在Downloadable中得到一个例外
    private var _baseFolder:File = new File(\"app-storage:/\");
错误:
SecurityError: file
at runtime::SecurityManager$/checkPrivilegeForCaller()
所以-我需要怎么做才能防止此类安全错误?我希望将远程SWF视为在与AIR代码相同的安全沙箱中运行的本机代码。     
已邀请:

bab

        我不确定Android,但是对于普通的网络播放器,您需要为Loader上下文的securityDomain指定SecurityDomain.currentDomain,以便在权限方面将加载的代码视为等同于加载器。另请注意,由于无法解释的原因,如果从PC上的文件系统加载Flash Player时使用SecurityDomain,则会抱怨。 不管多么复杂,Flash Player的安全性通常都是默默无闻的安全性...因此,如果它不能按照您的编码方式工作,请尝试Loader.loadBytes()\“ workaround \”。     
        
function loadAndRunSwf()
{
    var context:LoaderContext=new LoaderContext(false);

    context.allowCodeImport=true;

    var ba:ByteArray=new ByteArray();
    var file:File = File.applicationStorageDirectory.resolvePath(\"downloadable.swf\");
    var fileStream:FileStream=new FileStream();
    var loader:Loader = new Loader();

    fileStream.open(file,\"read\");
    fileStream.readBytes(ba);
    ba.position=0;
    loader.loadBytes(ba,context);
    this._main = new NativeWindow();
    this._main.width = 1024;
    this._main.height = 768;
    this._main.stage.addChild(loader);
    this._main.activate();
}
    

要回复问题请先登录注册