6 Replies Latest reply on Feb 15, 2008 2:39 PM by

    Modules inside SWC?

      Hi, from what I can tell, modules can be used inside a single Flex Builder project just fine (identified as modules and compiled as SWFs), but I am not finding a way to compile Modules in a separate Flex Builder project and import them into the main project via a SWC. Has anyone done this before, or perhaps have a better solution than using a SWC project? thanks!

      Merf
        • 1. Re: Modules inside SWC?
          Michael_Latta
          You need to create a library project that produces an SWC then reference that project result in your SWF project both on the project references tab and also on the compiler or build path tabs.
          1 person found this helpful
          • 2. Re: Modules inside SWC?
            Gaurav J Adobe Employee
            Why do you want to import Modules via a SWC?

            The idea behind modules is to make your main app smaller so that you can speed up initial load time. And load module when required.

            if modules are inside a swc (which I think is not possible) you would not be able to load them at runtime.

            If you want to compile against a common code then you should use a library project and generate a swc or generate a RSL which you can load at runtime.

            Thanks,
            Gaurav Jain
            Flex SDK Team
            • 3. Re: Modules inside SWC?
              Thanks.. That's basically what I was doing.. but since a module is loaded via its URL, what is the URL format for accessing a module inside a SWC? All the examples and docs I could find do not address this issue.
              • 4. Re: Modules inside SWC?
                The purpose for doing the modules in a separate project is to reduce compile times for developers. The main project is very large and the module compilation is a big part of why it takes so long to compile. From what you are saying, it sounds like loading modules from a separate project is not possible, correct?
                • 5. Re: Modules inside SWC?
                  Gaurav J Adobe Employee
                  It is possible to load the modules from a different project. A module is after all a SWF so you theoretically be able to load it from a url (as long as you don't run into domain issues).

                  Here is what I would do.
                  1. Create a Flex Project in Flex Builder.
                  2. Add what ever modules, you need to add.
                  3. Delete the main app file (from this project).
                  4. Go to project properties - > Flex modules -> double click on all modules (one by one) and remove the option for Optimize for.

                  The disadvantage for moving modules to a separate project is that you loose capability for automatic "optimize for". This is used to reduce the size of the module by not duplicating classes which are already in the main application.

                  However there is a workaround:

                  In the main project (from which you want to move *out* all modules):
                  1. Go to project properties -> Flex compiler
                  2. In the additional compiler arguments add -link-report=lnkreport.xml (you can also give the absolute path for where you want the link report to be generated).

                  Now in the project which will contain modules.
                  1. Go to project properties -> Flex compiler
                  2. In the additional compiler arguments add -load-externs=lnkreport.xml (make sure path is same as what you gave in the main project).

                  This would make sure that modules in the separate project would be optimized for your main app.

                  Now since you moved them to a different project, you need to copy the compiled modules to the location specified by the url used to load the modules. or simply change the Output folder for the modules project by going to project properties -> flex build path

                  Let me know if you face any issues.

                  Thanks,
                  Gaurav Jain
                  Flex SDK Team





                  1 person found this helpful
                  • 6. Re: Modules inside SWC?
                    Thanks, Gaurav, that is in fact what i was starting to try. I did run into the sandbox error, of course, since the app can't load the URL of the module outside the main project by default. So I will need to expand the trust permissions on the main app. I will keep playing around some more and let you know if we continue to encounter any more obstacles. Thanks again.