0 Replies Latest reply on Feb 29, 2008 2:28 PM by Aaron34589

    "Module Domains" confusion

      Dear all,

      I'm currently playing around with Flex modules api and got very confused with the "Module Domains" section on the Adobe docs. It's under:

      Adobe Flex 3 Help -> Advanced Flex Programming -> Creating Modular Applications -> Modular applications overview -> Module domains.

      In that section, it basically talks about how class definitions can be "owned" by modules, how it affects the mysteriously undocumented "SingletonManager" thingy, and how singletons such as PopupManager might not work due to ownage. I've read through this section at least 5 times and have done quite a lot of testing but still couldn't figure out exactly what it means. Well, here is my questions below and I hope someone can shed my some insights or point me to a more detailed documentation regarding this topic:

      1. The doc says, "Because a module is loaded into a child domain, it owns class definitions that are not in the main application's domain."
      What does it mean by class definitions being "owned"? As far as i know, parent-child ApplicationDomain relationship is constructed in such a way that class definitions on child domains are overridden by the same (usually newer) class definitions on parent domain, but I don't understand what it means by "owning" it. This also leads to my 2nd question below.

      2. The docs then went on saying "For example, the first module to load the PopUpManager class becomes the owner of the PopUpManager class for the entire application because it registers the manager with the SingletonManager. If another module later tries to use the PopUpManager, Adobe ® Flash® Player throws an exception."
      Well I've tried to replicate this scenario by creating 2 modules and have each of them calling PopUpManager.createPopUp() on creationComplete event. I loaded up both modules from my shell application and the popups from both modules worked, i.e., i see 2 popups on screen. But according to the docs, I should get an exception when the 2nd module tries to run PopUpManager.createPopUp(). So why is this not the case?

      3. The docs also says, "This technique also applies to components. The module that first uses the component owns that component's class definition in its domain."
      So, I assume what it means is that such restriction affects not just singletons but normal objects as well. I tried another test by having module1 instantiates an object of classA, pass it on to module2, and then try to access it from module2. According to docs, I should also get an exception from the player; however, this is not the case. I was able to access the classA instance from module2 with no errors. Consequently, I also tried to instantiate classA from module1 and then instantiate another instance of classA from module2, and that also worked.

      As you can see, I'm really confused about almost everything mentioned in this "module domains" section and how it affects us in real life. Of course it's all nice and well that all my tests worked and no exceptions are thrown, but I really wish to get to the bottom of this and understand what "module domains" really implies in all these scenarios.