title: Adobe AIR : Worker can't load file
body: <p>I have an issue with Workers in AIR : when I try to open a file in a non-primordial Worker, I get a Security error. When I try the same code in the primordial Worker, it works well.
  I load another swf and pass its bytes when creating the second Worker.</p>
  
  <p>First, I tried with URLLoader (code in 2nd worker) :</p>
  
  <pre><code>// Loading XML test
  var loader:URLLoader = new URLLoader(new URLRequest('app:/config/generator/galaxy.xml'));
  loader.addEventListener(Event.COMPLETE, function(evt:Event):void
  {
      // Trace
      CEThreadDebugger.log(XML(loader.data).toString());
  });
  loader.addEventListener(IOErrorEvent.IO_ERROR, function(evt:IOErrorEvent):void
  {
      CEThreadDebugger.log(evt.text, CEThreadDebugger.ERROR);
  });
  loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(evt:SecurityErrorEvent):void
  {
      CEThreadDebugger.log(evt.text, CEThreadDebugger.ERROR);
  });
  </code></pre>
  
  <p>I get this error :</p>
  
  <pre><code>[LOG]ERROR-&gt;Error #2048: Security sandbox violation: app:/SombresCieux.swf cannot load data from app:/config/generator/galaxy.xml.
  </code></pre>
  
  <p>Then I tried with File :</p>
  
  <pre><code>var file:File = File.applicationDirectory.resolvePath('config/generator/galaxy.xml');
  var stream:FileStream = new FileStream();
  stream.open(file, FileMode.READ);
  var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable));
  stream.close();
  </code></pre>
  
  <p>And I get this error (my code is in _mainToWorker method) :</p>
  
  <pre><code>[LOG]INFO-&gt;Error #0 : SecurityError -&gt; file
  SecurityError: file
      at flash.filesystem::File$/initAppResourceDir()
      at flash.filesystem::File$/get appResourceDirectoryPath()
      at flash.filesystem::File$/get applicationDirectory()
      at generator::Generator/_mainToWorker()
      at engine.generic.system.concurrency::CEThreadMain/Evt_mainToWorker()
  </code></pre>
  
  <p>I noticed that the error comes from this line alone :</p>
  
  <pre><code>var file:File = File.applicationDirectory.resolvePath('config/generator/galaxy.xml');
  </code></pre>
  
  <p>So it works in the primordial Worker (main app), but not in the threads...
  Can't the Workers access system's files nor load any file ? It's a quite huge limitation...</p>
  
  <p>Thanks for the replies !</p>