I put together this presentation for the 360 Flex conference in San Jose. Thank you to those who attended and filled up the room so I could impress my manager with my supposed popularity.
The presentation contains a basic introduction to modules and how to use them, and an attempt to explain ApplicationDomains which are an important factor in how modules and RSLs (Runtime Shared Libraries) work.
The presentation is here: Download file
And some sample code is here: Download file
The sample code has build.script files that require a unix shell and show how some of the MXMLC parameters are used. (The usual caveats, disclaimers, and other legal stuff apply).

15 Responses to Modules

  1. William Chadwick says:

    Thanks for this cool presentaiton. Too bad you don’t post a AS3 version. I’m not a big fan of MXML.

  2. The presentation is a ppt… 😐
    😉 Just joking. Thanx for the presentation and source!

  3. Vladimir Pavlović says:

    I don’t know if this is good place to post question, but it’s module matter.
    I’m working on very big project using Flex (and modules). When I’m uploading new version of modules, browsers (IE, Mozilla…) cached old version, because of that new version is not loaded. This thing occurres sometimes, but not always!
    Does anyone know the solution for this problem?
    Thanks in advance!
    FlexCoders would be a good place to post this question

  4. games says:

    Great Point … Thank you for this Article

  5. Nisim Joseph says:

    10x on the presentation.
    i want to develop product and want to use the RSL (Runtime Shared Library) of the Flex. i don’t know the amount of use with this feature and i will be happy to get info on the amount of site that use this.
    it critical for the future of this project.
    we want that a lot of users that will come to our site will already have the RSL on their Flash Player.
    Alex responds:
    We don’t have exact numbers on the shared RSL, but it looks better every day. Ask on FlexCoders and you may get more definitive numbers

  6. Henry Rabinowitz says:

    Alex, a basic question…
    For Popup Modules, you recommend putting the TitleWindow inside the Module, like this:

    but if I do this, and use PopUpManager.addPopUp() to raise this object, it is not draggable. What is the solution?
    Alex responds:
    The answer should be in this post:

  7. Jeffrey A Lage says:

    i’m using flex 3. from looking at the docs, on the IFlexModuleFactory interface, the create() method allows for …args to be passed in to allow the module to return different objects.
    however, most of the examples i’ve seen the module is written in MXML and is essentially a 1-to-1 relationship with a single underlying DisplayObject. can you point me to any examples that show how to override this behavior to allow a module to generate multiple types of DisplayObjects? i would like to end up with a module that contains all of the screens i have related to a particular functional area of my app. not a module for each screen.
    Alex responds:
    You can pass parameters to the factory, but I don’t have any good examples of how or why.
    Any classes in the module (assuming they aren’t already in the main app) can be factoried by passing the name of the class to the factory method.

  8. Alex,
    Thanks. Even after working in Flex for long, I found I didn’t know many things present in this presentation. Pure Gem. I am scared of PPTs as sometimes they lack real content. This one had it.

  9. Aravind says:

    How do we communicate between screens within a Module?
    Ex: I have Screen1 and Screen2. If I change data on Screen1, according to that I have see changes on Screen2 and vice verse.
    How do we do achieve these changes in Flex Module?
    Alex responds:
    These days, I recommend everyone use a model-view (MV) or MVC architecture. Then interaction in one view/screen affects the data model and the other screen/view is watching for changes to that model via data binding

  10. Ramon Rubio says:

    I’m developing a flex portal that integrates ui from different providers.
    Is it possible to do the following?
    From my main application i want to be able to load modules into a sibling application’s domain.
    Currently I’ve done the following.
    1. Used SwfLoader to load a sub-application into a new application domain (as a sibling of main application domain).
    2. From the main application used ModuleLoader to load modules into application domain created in step 1. As a parameter into module loader we specified the application domain of the sub-application created in step 1.
    The result is that the module loads but its application domain is set to the main application.
    Any ideas?

  11. Alex Harui says:

    I’m not sure how you are getting the appdom of the sub-app. Maybe you are in the wrong context? It might be safer to have an API between appdoms so the sub-app loads its own modules.
    Remember that modules are tightly bound to their loader so any API changes between versions will cause issues

  12. vineet says:

    This is really a good presentation . After going through it came to know lot about flash player. looking forward for more of such “under the hood” information .

  13. Adrian says:

    i have the same problem what , i read this article and it seems that your blog helped him , but i don’ know how exactly, what has hi done?

  14. David Baron says:

    Hi Alex,

    I am new to Flex, but am very experience in terms of app building, coding and such. I am trying to put together a Flex app that has many ‘pages’, to be implemented by modules, which will then get loaded as and if necessary into various view stacks and such. I am now at the point where I need/want to use Interfaces.

    The basic gist is this: The Main App has a viewstack. Into the viewstack I use ModuleManager to load Module 1 – no interface needed (from what I can tell). This works great. Module 1 works completely independantly of The App. However… now I want Module 1 to load Module 2 into a viewstack of *its* own. And… I need interfaces to make it ‘nice’ to deal with. Again, I am using ModuleManager and ActionScript to do all this. I have an interface for Mod. 2. I can ‘load’ Mod 2 from Mod 1 and ‘addChild’ it into the viewstack just fine. However…I cannot seem to ‘cast’ it as the ‘interface type’ – the cast variable always comes back null. I have seen and tried many variations of ‘factory.creating’ the moduleInfo object, only to fail (null) every time. Would you be able to assist me in trying to see what I am not quite getting? I can of course send you some simple code.

    Thank you very much,