3 Replies Latest reply on Mar 13, 2012 5:30 AM by Sercan Altun

    Embeding symbols from a swf created with mxmlc

    Sercan Altun

      Hello everyone,

       

      I am trying to bundle my resources in seperate swf files then use them in another flex project. I create this bundles from a wizard i wrote in AIR. AIR app calls mxmlc to compile bundle.as and i dynamicaly load bundle.swf. I can access resources from this bundled swf using ApplicationDomain.getDefinition(). No problem there

       

      However i also want to use my wizard to edit prexisting bundles. Problem is i cannot embed resource from original bundle to new bundle. I mainly use Sprite and ByteArray assets in bundles.

       

      To simplfy problem i prepared following test. Created a bundle application to create bundle swf in flex. The project has 4 files: 2 .as files, 1 .png file, 1 .swf file( from FLA which has a symbol linked "Fill" )

       

       

      // Bundle.as
      package
      {
        
                import flash.display.*;
        
                public class Bundle extends Sprite
                {
                          public function Bundle()
                          {
                                    var fla:DisplayObject = new Fla();
                                    addChild(fla);
        
                                    var image:DisplayObject = new Image();
                                    addChild(image);
        
        
                          }
                }
        
      }
      
      
      // Image.as
      package
      {
                import flash.display.Bitmap;
        
                [Embed(source='plus.png')]
                public class Image extends Bitmap
                {
                }
        
      }  
      // Fla.as
      package
      {
                import flash.display.Sprite;
        
                [Embed(source='fla.swf', symbol="Fill")]
                public class Fla extends Sprite
                {
                          public function Fla()
                          {
                          }
                }
      }
      
      
      

      Project above compiles without problem and i can see both assets on screen.
      Then i create a second project which will use swf created from project above.

       

       

      package
      {
        
                import flash.display.*;
        
                public class Application extends Sprite
                {
                          [Embed(source='Bundle.swf', symbol='Fla')]    /// Flex cannot embed this
                          private var flaClass:Class;
        
                          [Embed(source='Bundle.swf', symbol='Image')]  /// But it can embed this
                          private var imageClass:Class;
        
                          public function Application()
                          {
                                    var fla:DisplayObject = new flaClass();
                                    addChild(fla);
        
                                    var image:DisplayObject = new imageClass();
                                    addChild(image);
                          }
                }
        
      }
      
      

       

      The second project can only see Bitmap  asset as symbol. But could not find Sprite asset.

       

      We depend heavily on vector graphics from Flash, and byte array assets embeded with

       [Embed(source='x.ba', mimeType="application/octet-stream")]
      

       

      I could write byte array assets into a temp dir and embed them again but i cannot do it with Sprites. How can i solve this problem.