4 Replies Latest reply on Jul 27, 2006 4:56 PM by mike2281


    mike2281 Level 1
      I am developing a large flex app making extensive use of libraries.

      The build path of each library is manually set in the root of the web

      When I build each library it creates the swc file in the correct directory.

      The main app is setup in the same web root at /RIA/MainApp/ and links to the library with using an RSL and specifying RSL URL as /RIA/Lib1/lib1.swf

      How do I get the libraries to create the swf file when I build, currently it only creates the swc file?

      I know I can check the box to create the swf when I build the main app, but it places it the main apps source folder, this can be copied over, but it’s a pain to do each time.

      I don’t want the lib1.swf located in the main apps source as there will be other sub apps using the same library with an RSL pointing to the library’s folder and that would cause the library to be loaded multiple times one for the main app and other times for the sub apps or other libraries using each other, if I understand this correctly.


        • 1. Re: RSL URL
          I believe that you can change the RSL URL as well and have the application build the swf and put it in the location that you specify. Under project settings, Flex Build Path, Library path, you open a particular library, select the RSL URL and click on the Edit... button. (You'll still have to do this for each application's project, but it beats copying the file over on each build.)

          Does that work for you?

          Rebecca Hyatt
          • 2. Re: RSL URL
            mike2281 Level 1
            When I check the auto extract swf it places the swf in the projects root folder of that project, this would be fine if I only had one project, but I have other projects that are essentialy child apps and they would then each have a copy in their source folder which means that library gets loaded again in the child app as it is in a different location.

            Here is another observation about flex and merged code....Any thoughts are greatly appreciated.

            The main flex library is just over 1 meg, if you add in charting it’s close to 2 megs.

            When you create a project and start adding applications to it even small ones are around 200 – 400 K each and they seem to each contain copies of the dependencies, so it appears that each app in the project contains merged code, the needed parts of the flex framework.

            So in a medium size app why not load / cache the framework libraries once and have apps that range from 10 – 20 K.

            In a project you would normally have a main app that is a loader for the child apps, so the child apps don’t need to contain the dependencies already loaded when the main app loads, however based on the file size it appears that each app contains it’s own copy of the parts of the framework it needs.

            So even better would be a way to have flex know that a main app will always be loaded first so it does not embed identical resources into each child app.
            • 3. Re: RSL URL
              Rebecca_Hyatt_-Adobe Level 1
              Ah, so it's ignoring the RSL URL when it comes time to do the auto-extract? That's unfortunate.

              My next guess is that you might be able to make this work by playing with the additional command line options in the library project. I think you want -directory=true. I've tried this out locally, and my library project called "Shapes" created "bin/Shapes.swc" as a directory instead of a zip file. In other words, I can now reference the SWF directly with "bin/Shapes.swc/library.swf". The path is a bit weird (it would be more straightforward if the SWF were directly inside the bin folder), but I think it will get around your problem.

              Unfortunately, while this makes the compiler happy, our code model (which is behind code hints, go to definition, and such) no longer has a SWC to read to learn about all of the classes defined in your library. So none of those features know about the library classes. Arg.

              Maybe if you make two library projects for each library source folder... one with directory=true that extracts the SWF and one without that builds the SWC. (Use a linked folder to share source between them.) Include the latter in the build path for your project, but set its RSL URL to point to the SWF in the former. Then both the compiler and the code model should be happy. Not that this is getting at all complicated...

              You could always give in and put the main application and the sub applications into the same project and just use the version of the SWF that's generated in that project's output folder. Or maybe the right solution here is to allow the multiple copies of the SWFs during development, then (after you get things working) build things the way you like them using the command-line compiler in a batch.

              In the meantime, I'll make sure to file some sort of enhancement request to untangle this mess.

              Rebecca Hyatt

              P.S. As to the more general comments about limiting loads of shared content between multiple applications... I recommend posting a new topic on the Flex 2 General Discussion forum to see if you can drum up some discussion. That way, it won't get lost here on the forum for tool-specific stuff.
              • 4. Re: RSL URL
                mike2281 Level 1

                Thanks for providing such a detailed response. I just started examining a strategy for creating a very large modular dashboard app with literally hundreds of child apps, this is being converted from a browser based AJAX app and we are so happy to be using FLEX! And have a true type safe environment.

                That said lets consider the following structure each APP is an swf….

                [MAIN APP]

                [CHILD APP A]
                [CHILD APP A_1]
                [CHILD APP A_2]

                [CHILD APP B]
                [CHILD APP B_1]
                [CHILD APP B_2]

                Main app is always loaded, so Child A would never contain any duplicate framework or library code.

                Child A is always loaded before Child A_1, so Child A_1 would never contain any duplicate framework or library code already in Main or Child A.

                I think if this were possible Main would be the same size as it is now, but Child A and Child A_1 would be much smaller.

                So in Flex Builder we have one app in the root, and create a dependency chain using the same folder structure used to create package namespace chains…

                Main.swf [Default]
                /ChildA/Main.swf [Default]

                Child A could also be broken into another project, and [Default] could signify the parent.

                I have posted my earlier findings on file size in the general forum, and will continue to search for the best solution to duplicate merged code and decreasing the file size.