2 Replies Latest reply on Oct 12, 2007 9:59 AM by levancho

    Need help with moduleloader quirks

    enfantterrible-tijzQ7 Level 1
      I've been trying to build a modular application by using the ModuleLoader to keep the seperate features as small as possible. I've been using mostly "mxml" applications and compnents. While I was experimenting with very simple applications I had no problems. But since I've been adding more features to the applications I've been encountering some troublesome serious problems.

      For example when I have more than 1 module open and I try to unload a module by using either *.url = "" or *.unloadModule() I get the following an error, see error 1 bellow.

      Also when I have more than one module open, a module that has a popup window with a ButtonBar does not open and gives me an error, if I remove the button bar the popup windows opens, see error 2 bellow.

      I would appreciate some inpute from people who have used the ModuleLoader, should I abadone the use of the ModuleLoader totally, would using Actionscript files/classes be more stable than using mxml?

      Any input would be greatly greatly apreciated, thank you!!!


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.managers::HistoryManager$/unregister()
      at mx.containers::Accordion/::systemManager_removedHandler()
      at flash.display::DisplayObjectContainer/removeChild()
      at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::$removeChild()[E:\dev\flex_201_borneo\sdk\fram eworks\mx\core\UIComponent.as:4693
      at mx.core::Container/removeChild()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core\Container. as:2309]
      at mx.modules::ModuleLoader/unloadModule()[E:\dev\flex_201_borneo\sdk\frameworks\mx\modules\ ModuleLoader.as:285]
      at nbt_2/exitCalled()[C:\Inetpub\wwwroot\ccradius\public\nbt_2\nbt_2.mxml:445]
      at nbt_2/nbt_2::makeCommand()[C:\Inetpub\wwwroot\ccradius\public\nbt_2\nbt_2.mxml:345]
      at nbt_2/nbt_2::itemClickHandler()[C:\Inetpub\wwwroot\ccradius\public\nbt_2\nbt_2.mxml:212]
      at nbt_2/__myMenu_itemClick()[C:\Inetpub\wwwroot\ccradius\public\nbt_2\nbt_2.mxml:502]
      at flash.events::EventDispatcher/flash.events:EventDispmatch has been found: nbt_2_0.mdHolder.contactsManager_Ldr
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core\UIComp onent.as:8389]
      at mx.controls::MenuBar/mx.controls:MenuBar::eventHandler()[E:\dev\flex_201_borneo\sdk\frame works\mx\controls\MenuBar.as:1341]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core\UIComp onent.as:8389]
      at mx.controls::Menu/dispatchEvent()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\Menu. as:1172]
      at mx.controls::Menu/mx.controls:Menu::mouseUpHandler()[E:\dev\flex_201_borneo\sdk\framework s\mx\controls\Menu.as:1465]

      Error 2:
      TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::ButtonBar@b2530a1 to mx.controls.ButtonBar.
      at mx.skins.halo::ButtonBarButtonSkin/mx.skins.halo:ButtonBarButtonSkin::updateDisplayList()
      at mx.skins::ProgrammaticSkin/validateDisplayList()[E:\dev\flex_201_borneo\sdk\frameworks\mx \skins\ProgrammaticSkin.as:418]
      at mx.managers::LayoutManager/mx.managers:LayoutManager::validateDisplayList()[E:\dev\flex_2 01_borneo\sdk\frameworks\mx\managers\LayoutManager.as:600]
      at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[E:\dev\flex _201_borneo\sdk\frameworks\mx\managers\LayoutManager.as:655]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[E:\dev\flex_201_borneo\s dk\frameworks\mx\core\UIComponent.as:7975]
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[E:\dev\flex_201_borneo\sd k\frameworks\mx\core\UIComponent.as:7918]
        • 1. Re: Need help with moduleloader quirks
          enfantterrible-tijzQ7 Level 1
          for the benefit of the new recruits out there like me with similar problems. These problems only seem to arise when more than one module is open at the same time. This problem was happening in Flex 2 and Flex 3 beta and I wish the issue was a little better documented in the Adobe documentation. And it didn't matter whether I had created the components with xml or AS. But for now all seems to be working. The problem seems to be if the components are not initiated in the main application, and another module uses the components for what ever reason which is above my abilities, they don't get initialized in the subsequent modules. The solution is to initialise the components in the main application for me it was something like: (at least this worked with 2 simultaneiously opened modules that were giving me problems)

          import mx.containers.*;
          import mx.managers.*;
          public var frstAccordian:Accordion;
          public var frstViewStack:ViewStack;
          public var frstBtnBar:ButtonBar;
          public var hm:HistoryManager;

          Hope this helps future generations...


          • 2. Re: Need help with moduleloader quirks
            levancho Level 3
            no, you should not abandon module loader at all, I have been using module loader very successfuly and its one of the best parts of flex,
            first error seems to be related to history manager? are you using browser history integration? if not you might want to completely get read of all that history mess, an also instruct compiler not to generate history files etc ... (that should take care of your first issue)
            now second issue is very interesting I think the root problem lies within how you are duing module loading .
            I would suggest following way : (at very early state of application initialization do this :
            private function someFunc () {
            var info:IModuleInfo = ModuleManager.getModule("yourModule1.swf");

            // module to be loaded and created.

            // info.unload();

            now this will just start preloading your module and dont display it yet,

            next (since you have registered a function(listener) that will ge clled when this module is fully loaded :

            private function modEventHandler(e:ModuleEvent):void {

            myModuleLoadedAndCreated = e.module.factory.create();