3 Replies Latest reply on Jul 23, 2007 9:46 AM by levancho

    ModuleLoader or SWFLoader ?

    Yann Martel Level 1
      Hello everybody,

      I have a few questions regarding the Module classes. I don't really understand the difference between loading an Application from a swf or loading a Module from a swf. From what I've seen in the docs the ModuleLoader allows to load multiple instance of a same Module. Is that the only advantage of using Modules ?

      Another thing I noticed is that ModuleLoader can load and unload while SWFLoader only has a load method. Is it "cleaner" to use a ModuleLoader if I need to often load/unload swf files ?

      The application I'm building works by interacting with a loaded swf. It only uses one swf at a time. The user can switch between several swf. For the moment I'm using a SWFLoader, and when the user chooses another swf, I remove the SWFLoader with removeChild() and creates another one to load the new swf.
      Should I be using Module classes instead ?

      I'm a bit confused for the moment so I'd appreciate any explanation.
        • 1. Re: ModuleLoader or SWFLoader ?
          levancho Level 3


          if swf is generic file that has nothing to do with flex code then use it as swfLoader,
          if swf asset is compiled flex code I would suggest using it as Module(you might have to modify and put it under mx:module tags) then you can exchange API and call functions etc inside that swf asset from main application and visa versa..

          • 2. ModuleLoader or SWFLoader ?
            Yann Martel Level 1
            Thanks for the reply.
            I've replaced my SWFLoader with a ModuleLoader and changed my swfs as Module instead of Application and it does work.

            However, it also worked before. It is possible to call the functions of swf loaded with SWF Loader with something like this:

            var loadedSM:SystemManager = SystemManager(swfLoader.content);
            var loadedApp:*=loadedSM.application;
            loadedApp.callAMethod();

            I guess using Module is a cleaner way of doing it, so I'm gonna stick with it, even though I'm not sure it is really better.
            • 3. ModuleLoader or SWFLoader ?
              levancho Level 3
              I have not used swfLoader , but with Module you can do a lot of fancy stuff like preload it and unload it as needed .I gues Swf is more general solution where you can load basically any kind of swlf right?
              ooh and with module you can also remove unnecessary code for example : say if some resource as class, etc is already in main application you tell compiler to exclude that from module when it compiles it.