1
votes

I'm creating an app that loads other swf files, these 'windows' do different (and sometimes complicated) things.

I want to load a swf file that's downloaded to the documentsDirectory and loaded with a Loader, that works fine.

If the swf wants to acces a FTP-server i get the following error

*** Schending van beveiligingssandbox ***
Verbinding met ftp.strato.com:21 gestopt niet toegestaan vanaf file:///Users/alwin/Documents/ServConnect%20Manager/Apps/com-alwinlubbers-upallcars
Fout: Aanvraag voor bron op xmlsocket://ftp.strato.com:21 door aanvrager van file:///Users/alwin/Documents/ServConnect%20Manager/Apps/com-alwinlubbers-upallcars is geweigerd, omdat beleidsbestandsmachtigingen ontbreken.

Roughly translates to:

*** Violation of security sandbox ***
     Connection to ftp.strato.com:21 stopped not allowed from file: ///Users/alwin/Documents/ServConnect%20Manager/Apps/com-alwinlubbers-upallcars
     Error: Request for resource at xmlsocket: //ftp.strato.com: 21 by requesting file: ///Users/alwin/Documents/ServConnect%20Manager/Apps/com-alwinlubbers-upallcars because policy file permissions are missing.

It connects to the server via a Socket. The swf loaded via a normal Loader with Loader.load(File.url).

LoaderContext:

var appCont:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
appCont.allowCodeImport = true;

To summarize: The parent app is an Desktop AIR-app, the loaded swf gets downloaded from the server to the documentsDirectory of the user, inside the folder 'ServConnect Manager/Apps/{AppID}'. When it's downloaded, it gets launched with the Loader, so when it loads, it's a local swf file. The loaded swf wants to connect to an FTP-server to get some files, but it can't, because of the 'security' sandbox.

Thanks in advance. -Alwin

1

1 Answers

1
votes

I've fixed it by loading the swf using .loadBytes() instead of .load().

First, i've loaded the swf with a loader to a byteArray like this:

    var my_url1:URLRequest = new URLRequest("SWF/Lesson1.swf");
    var urlloader:URLLoader = new URLLoader(my_url1);
    urlloader.dataFormat = URLLoaderDataFormat.BINARY;
    urlloader.addEventListener(Event.COMPLETE, function(event:Event):void
    {
        var myByteArray:ByteArray = URLLoader(event.target).data as ByteArray;
        trace(myByteArray.length);
    });

Source: Load external swf into bytearray with adobe flash

Next, i've loaded the swf in the main Loader using .loadBytes(myByteArray, appCont)