2 Replies Latest reply on Jun 10, 2010 1:09 PM by ozster123

    loading local swf into a remote sandbox using mx:html control

    ozster123

      Hi,

       

      I have a swf which expects to run in a remote sandbox, ie is normally loaded from http://mydomain/test.swf. It will then access files from the location it was loaded. So this works fine if I load the swf using the browser.

      Now my air application caches this swf and all its required files to a folder under the app-storage folder. My goal is to load this swf from within my air application. I can't use the normal swfloader as this will use the application sandbox and I get security errors when the loaded swf tries to access files. My next attempt was to try and create a remote sandbox using a mx:html control.

       

      var file:File = templateFolder.resolvePath("loader.html");
      var request:URLRequest = new URLRequest(file.url);
      _iHtml.htmlLoader.load(request);

       

      loader.html contains:

      <html>
        <body>
          <iframe id="UI" src="http://www.xyz.com/air/test.html" sandboxRoot="http://www.xyz.com/air/"
           documentRoot="app-storage:/template/"
           style="background-color: #ffe; width:100%; height:100%">
          </iframe>
        </body>
      </html>

       

      (xyz being replaced with a real domain) (test.html just contains simple text as a test)

       

      My logic here is that the file test.html will be mapped to the documentRoot folder and loaded. This does not happen and I get a not found url message from the domain server.

      Questions:

      Can I use the sandboxRoot/documentRoot attributes with the mx:html control?

      If these are valid then what am I doing wrong.

       

      Many thanks,

       

      John

        • 1. Re: loading local swf into a remote sandbox using mx:html control
          Joe ... Ward Level 4

          "Can I use the sandboxRoot/documentRoot attributes with the mx:html  control?"

           

          Yes, mx:HTML is just a Flex wrapper on the HTMLLoader object. Have you verified that test.html is actually in the "app-storage:/template/" folder when your app loads?

           

          The iframe sandbox bridge feature was designed to map application content into a different security sandbox, not to map arbitrary non-app content into a different domain. So it's possible that this technique won't work. Try putting the template folder and the files into the application directory and change the documentRoot attribute to "app:/template/". If that works, then the technique probably isn't supported. If it doesn't work, then I'd suspect a problem with your application code.

          • 2. Re: loading local swf into a remote sandbox using mx:html control
            ozster123 Level 1

            Yeah the files are in the template folder. I have also tried moving them to a app:/template folder with no joy. I can get the test.html file to load by setting the src="app-storage:/template/test.html" but other content is not mapped as expected, for exampe the <img src="http://www.xyz.com/air/image0.jpg"/> is not loaded from the app-storage:/template folder.

             

            The iframe sandbox bridge feature was designed to map application content into a different security sandbox, not to map arbitrary non-app content into a different domain.

            I read that differently from the documentation, http://livedocs.adobe.com/flex/3/html/help.html?content=AboutHTMLEnvironment_5.html, the following text seem to suggest that all content urls are mapped.

            When resolving URLs, either in the frame src attribute, or in content loaded into the frame, the part of the URL matching the value specified in sandboxRoot is replaced with the value specified in documentRoot.