1 Reply Latest reply on Aug 25, 2010 9:53 AM by Flex harUI

    importing flash symbols from an external SWF using URLrequest


      I'm trying for several days now to properly import flash symbols into a flex application.
      i can't only @Embed because the swf file that contains the skins will not be available locally so i need to use URLRequest.


      This is what I've got so far.


      1. I created a flash file, lets call it foo.swf that contains several elements in the library and each element has both `Export for ActionScript` and `Export for runtime sharing` on. one of the elements is called 'test' which is a movieclip of an image.


      2. i created a flex project that creates the swf flashSkins.swf that contains the following Wrapper class:


                  import flash.display.Sprite;
                      public class Wrapper extends Sprite
                          [Bindable]public static var test: Class;


      I tested to make sure that this class properly fetchs symbols from the flash file properly
      using the following code:


                  public var wrapper:Wrapper;
              <mx:Image source="{Wrapper.test}"/>


      it loads the image and shows it properly.


      3. I created another swf file that will fetch the flashSkins swf and import the Wrapper class from it. this is where i fail.


              public function loadSkins():void
                      bgLoader = new Loader();
                      var bgURL:URLRequest = new URLRequest('http://files.xpogames.com/flashSkins/flashSkins.swf');
                  public function onLoaded(e:Event):void {
                      var clazz:Class = bgLoader.contentLoaderInfo.applicationDomain.getDefinition('Wrapper') as Class;
                      var a:Object = new clazz();
              <mx:Image id="theimage" />


      I tried using getDefinition with 'wrapper' or 'Wrapper' but on both cases i get an error that the variable is not defined.


      any ideas?