3 Replies Latest reply on May 2, 2007 6:23 AM by peterent

    Flash Library Assets Loading into Flex at Runtime?

    andrew76rocks
      What is the best way to accomplish the following:

      - User makes selection in simple form
      - Based on selection, the Flex app would THEN load the proper swf
      (library assets that are movieclips)
      - Library movieclips (class instances) to be used in Flex containers as
      needed

      I understand and have tried the Flex to Flash Kit but i don't think this
      is the route to go as this would load all the many swfs in at the start
      of the app?? Also i could embed the movieclip symbols using embed method
      but does this load the entire swf when first referencing a single class?
      I'm thinking that using the Loader class is the way to go for this as I
      could offer a preloader to client - but then not sure how to access
      symbols?

      I need help understanding how all these methods differ in terms of how
      swf's are loaded and dealt with within Flex. Help!!!
        • 1. Re: Flash Library Assets Loading into Flex at Runtime?
          peterent Level 2
          What you are describing sounds like a use-case for Flex 2 Modules. A Module is like an application in that it compiles to a SWF, but it cannot be run independently. Check the Flex 2 docs for Modules and I've got an example on my blog ( http://weblogs.macromedia.com/pent).
          • 2. Re: Flash Library Assets Loading into Flex at Runtime?
            andrew76rocks Level 1
            Thanks Peter, but there doesn't seem to be much documentation or examples for using Modules in this capacity. I understand you can load a module into an application at runtime but then what method would you use to load in your swf/class symbols and then use these assets in your application containers? Would the swf symbols be accessable to the entire application or just the module?

            Also, what does it mean to "package" your swc's in a module. I've heard of this approach, but again, never seen any examples of this.

            I've also seen older examples of using Loader and ApplicationDomain to load in embedded symbols of a flash movie. Would you recommen this or is there something else less cumbersome?


            • 3. Re: Flash Library Assets Loading into Flex at Runtime?
              peterent Level 2
              A "SWC" is a library of ActionScript classes. You can create one with Flex Builder by selecting a "Flex Library" project. A Module would simply use classes from the SWC (you add the SWC to your Module's build path) and then the resulting SWF would contain those classes. Note that only classes where are referenced by code in the module will be in the SWF.

              Read up on ApplicationDomain, I think that will make it easier to understand how to use classes that are loaded dynamically.