1 Reply Latest reply on Jun 10, 2010 7:12 AM by Fabrice3D

    ApplicationDomain.currentDomain; Does it work????

    Fabrice3D

      I have an AIR app that loads plugins (at least thats the idea)

      these swfs can be either AIR compiled or regular swf.

       

      In many cases the plugins are using same external library (Away3D in this case).

      So main app must not see these objects as different types.

       

      var context:LoaderContext = new LoaderContext();

      context.applicationDomain = ApplicationDomain.currentDomain;

       

      var loader = new Loader();

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

      loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

      loader.load(request, context);

       

      TypeError: Error #1034: Type Coercion failed: cannot convert somelib.utils::SomeClass@1cc8a0b1 to somelib.utils.SomeClass.

       

      same for all kinds of classes... from swf, all returns I get from mainapp are of type Object;

       

      context.applicationDomain = ApplicationDomain.currentDomain;

      Its supposed to be made for this no? If not what is the fix for this issue?

       

      Is there some way to let loaded class set it applicationDomain to ApplicationDomain??

      Some AIR specific way to handle this kind of structure?

       

      Fabrice

        • 1. Re: ApplicationDomain.currentDomain; Does it work????
          Fabrice3D Level 1

          using a trick like this, I can now avoid the previous conflict.

           

          --> I parse the disc plugin folder and read one by one the files.

           

          private static function loadPlugin(f:File):void

          {

             var stream:FileStream = new FileStream();

          stream.open( f , FileMode.READ);

          var ba:ByteArray = new ByteArray();

          stream.readBytes(ba,0,stream.bytesAvailable);

           

          var loader:Loader = new Loader();

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

           

          var lc:LoaderContext = new LoaderContext();

          lc.allowLoadBytesCodeExecution = true;

           

          loader.loadBytes(ba, lc);

          }

           

          So works now for the shared classes, but not for all classes...

           

          Anyone has experience or uses

          the sandBoxBridge parent/child thing successfully in a similar case?