title: AS3 Air for Android [Error 2070] - Remotely loaded SWF cannot access Stage from App
body: <p>I am building an Air for Android (AS3) application that will load remote swf files (located on my server)</p>
  
  <p>The idea is to keep the apk as stream lined as possible to allow fast deployment (will be deployed privately and not over Google Play)</p>
  
  <ul>
  <li>The apk is called the Loader</li>
  <li>The remote swf is called the Player.</li>
  </ul>
  
  <p>Now, Player is throwing up this error when I launch Loader:</p>
  
  <blockquote>
    <p>SecurityError: Error #2070: Security sandbox violation: caller <a href="http://sub.mydomain.com/remote/player.swf" rel="nofollow">http://sub.mydomain.com/remote/player.swf</a> cannot access Stage owned by app:/Loader.swf.</p>
  </blockquote>
  
  <p>This is odd as Player does not try to call the Loader stage - I told Player to make a new stage called "_stage", code below:</p>
  
  <pre><code>var playerContainer:MovieClip = new MovieClip();
  var _stage:Stage = playerContainer.stage;
  </code></pre>
  
  <p>Using:</p>
  
  <pre><code>_stage.stageWidth
  </code></pre>
  
  <p>to access the stage width.</p>
  
  <p>I have no idea why Loader thinks Player is trying to access it's stage properties?</p>
  
  <p>I have tried the following pieces of code that I have seen mentioned in various forum posts, but nothing seems to alleviate the problem with the security domains:</p>
  
  <p>In Loader</p>
  
  <pre><code>try {Security.allowDomain("*");}catch (e) { };
  </code></pre>
  
  <p>In Player</p>
  
  <pre><code>Security.allowDomain("http://sub.mydomain.com");
  </code></pre>
  
  <p>and also in Player, for my init() function</p>
  
  <pre><code>addEventListener(Event.ADDED_TO_STAGE, displayLogin);
  </code></pre>
  
  <p>Neither of these help.</p>
  
  <p>I am at a total loss. It's above my head as to how to get Loader to allow Player access to its stage properties.</p>
  
  <p>EDIT - when both swf files are on the server, and I access Loader via a browser, rather then using the android app, it loads fine. Definitely an issue with cross scripting, but it looks to me like I have all the right code to allow that?</p>