4 Replies Latest reply on Mar 6, 2008 12:44 PM by enorton@adobe

    Load external SWF into AIR app fails?

    patrickcheatham
      Hi there:

      Using the following code (inline; I don't see a choice to attach code), I can successfully load a SWF from the computer into my "app" during preview. When I export the app and test, I get a big nothing.

      I have the load complete function setting the text of a textfield to say "done", and it does so in either case.

      What am I missing that's overly obvious?

      Thanks in advance!


      quote:


      var myCoolMC:MovieClip;
      var loader:Loader = new Loader();
      addChild(loader);

      var loaderContext:LoaderContext = new LoaderContext();

      loaderContext.applicationDomain = ApplicationDomain.currentDomain;

      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

      loader.load(new URLRequest("file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/base/blah.swf"));

      function loadComplete(e:Event) {
      fileName.text = "DONE!";
      myCoolMC = e.target.content;
      }

        • 1. Re: Load external SWF into AIR app fails?
          patrickcheatham Level 1
          OK, so I reinstalled the debugger player, and now I'm able to get some feedback...

          quote:


          ** Security Sandbox Violation ***
          SecurityDomain 'file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/base/blah.swf' tried to access incompatible context 'app:/Untitled-3.swf'
          SecurityError: Error #2047



          So does this mean I can't have my child SWF load things into itself?

          Am I going about things the wrong way? ...I don't have control over the first SWF I load; I can call on its classes once I load it, though.

          Thanks in advance for _any_ insight.
          • 2. Re: Load external SWF into AIR app fails?
            enorton@adobe Level 1
            Hi Patrick,

            Well, you can load external content. However, they will not be in the same sandbox, and as such will have security restrictions applied accordingly. If 'file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/base/blah.swf' is attempting to cross script it's parent, there are restrictions here.

            When you say that you don't have control over the first SWF loaded...I'm unclear which is the "first". Is that the application's root SWF? The one loading 'file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/base/blah.swf' ?

            The first thing I'd take a look at (if possible) is to trace out Security.sandboxType from each of the SWFs.

            -Erica
            • 3. Re: Load external SWF into AIR app fails?
              patrickcheatham Level 1
              Hi Erica:

              :)

              Thanks for the response...

              The Parent/container SWF is "Untitled-3.swf". It loads (successfully) "blah.swf". Parent passes a file path (6 JPG images) to blah.swf, which blah.swf then tries to load.

              Paths for each are:
              parent AIR app (exported from Untitled-3.fla)--
              file:///Volumes/1.36 RAID/20080228_AIR_Tests/Untitled-3

              blah.swf --
              file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/base/blah.swf

              images --
              file:///Volumes/1.36 RAID/20080228_AIR_Tests/_panos/panos/sfcm/images/blah.jpg [...]

              quote:

              The first thing I'd take a look at (if possible) is to trace out Security.sandboxType from each of the SWFs.


              I'll try this out, but don't think I will be able to do that successfully, since blah.swf comes to me as-is, precompiled. (?)
              --
              Now, when I embed blah.swf in a Web page, it works A-OK on its own. Using (very cool, BTW) HTMLLoader, I can successfully load in the Web page and things function as normal. But, I can't seem to properly target the blah.swf in order to access its functions and/or get properties. I have tried ExternalInterface among other things. Ideas?

              Thanks again, and in advance...

              Patrick
              • 4. Re: Load external SWF into AIR app fails?
                enorton@adobe Level 1
                Instead of loading the paths absolutely, have you tried using a relative path? If you use file:/// it's not ever going to see it as app content.

                From Untitled-3, load (what API are you using?)
                "_panos/base/blah.swf"

                AIR's handles relative paths differently than Flash Player. In AIR, the relative path is relative from the movie calling it.

                SWF in HTML uses relative paths just as the Flash Player does (always relative from the root SWF)

                -Erica