5 Replies Latest reply on Feb 1, 2007 3:33 PM by digitalentropy

    Big Fat Ugly Module Bug

    Level 1
      Well, maybe it's not a big, fat, ugly bug, but it essentially doesn't allow us to port our application to modules.

      Anyway, here's the scoop. We have an application that has a module loader. When the application first starts, it loads this module:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module
      xmlns:mx=" http://www.adobe.com/2006/mxml" >
      <mx:TabNavigator />
      </mx:Module>

      This load fine without error. When I load the exact same module again, it barfs with the error below. In fact, this error only occurs after I load any module with a TabNavigator, when another module with a TabNavigator has been loaded before. It should be noted that I can put ANYTHING else in the module, and it will work fine, as along as ANYTHING is not a TabNavigator.

      Now, unless I am doing something wrong (which is not outside the realm of possability) this seems like a bug. ANYONE have any idea for a work around?

      here's the stack trace:
      [SWF] /flex/PMPortal/pmportal-debug.swf - 1,033,853 bytes after decompression
      [SWF] /flex/PMPortal/test.swf - 459,226 bytes after decompression
      [SWF] /flex/PMPortal/blank_app.swf - 481,007 bytes after decompression
      [SWF] /flex/PMPortal/test.swf - 459,226 bytes after decompression
      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.managers::HistoryManager$/register()
      at mx.containers::ViewStack/::addedHandler()
      at flash.display::DisplayObjectContainer/addChildAt()
      at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::$addChildAt()[C:\dev\flex_201_gmc\sdk\framewor ks\mx\core\UIComponent.as:4676
      at mx.core::Container/addChildAt()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\Container.as:2 278]
      at mx.core::Container/addChild()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\Container.as:221 4]
      at mx.core::Container/createComponentFromDescriptor()[C:\dev\flex_201_gmc\sdk\frameworks\mx\ core\Container.as:3721]
      at mx.core::Container/createComponentsFromDescriptors()[C:\dev\flex_201_gmc\sdk\frameworks\m x\core\Container.as:3533]
      at mx.core::Container/mx.core:Container::createChildren()[C:\dev\flex_201_gmc\sdk\frameworks \mx\core\Container.as:2618]
      at mx.core::UIComponent/initialize()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\UIComponent. as:4937]
      at mx.core::Container/initialize()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\Container.as:2 555]
      at test/initialize()
      at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\dev\flex_201_gmc\sdk\framework s\mx\core\UIComponent.as:4834
      at mx.core::Container/ http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\dev\flex_201_gmc\sdk\framework s\mx\core\Container.as:3347
      at mx.core::Container/addChildAt()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\Container.as:2 280]
      at mx.core::Container/addChild()[C:\dev\flex_201_gmc\sdk\frameworks\mx\core\Container.as:221 4]
      at mx.modules::ModuleLoader/mx.modules:ModuleLoader::moduleReadyHandler()[C:\dev\flex_201_gm c\sdk\frameworks\mx\modules\ModuleLoader.as:339]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at ModuleManager.as$117::ModuleInfoProxy/ModuleManager.as$117:ModuleInfoProxy::moduleEventHa ndler()[C:\dev\flex_201_gmc\sdk\frameworks\mx\modules\ModuleManager.as:1025]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at ModuleManager.as$117::ModuleInfo/readyHandler()[C:\dev\flex_201_gmc\sdk\frameworks\mx\mod ules\ModuleManager.as:704]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::FlexModuleFactory/::update()
      at mx.core::FlexModuleFactory/::docFrameHandler()

      Thanks,
      Andy
        • 1. Re: Big Fat Ugly Module Bug
          peterent Level 2
          What's your ModuleLoader look like? How are you changing it?
          • 2. Re: Big Fat Ugly Module Bug
            Level 1
            I have the ModuleLoader as the root tag of mxml, which is being held by an Application mxml. There is a menu on the left of the application that allows me to choose which module to load.

            The reason the ModuleLoader is called applicationLoader is because we used to load applications before, but I am now trying to switch that over to modules. Sorry about the confusion.

            The application mxml:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            xmlns:common="com.sundt.common.*"
            xmlns:pm="pm.*"
            x="0" y="0"
            percentWidth="100"
            percentHeight="100"
            paddingLeft="0"
            paddingTop="0"
            paddingBottom="0"
            paddingRight="0"
            backgroundColor="#FFFFFF"
            creationComplete="appCreated();"
            viewSourceURL="srcview/index.html">

            <mx:Script>
            <![CDATA[
            import mx.controls.Tree;
            import com.sundt.common.application_loader;

            private function appCreated():void
            {
            loader.setSelectedURL("test",null);
            }

            private function change(evt:Event):void
            {
            if (evt.currentTarget.id == "leftMenu")
            {
            if (evt.currentTarget.selectedItem.attributes.url != null)
            {
            var xmlNode:XML = XML(evt.currentTarget.selectedItem);
            var urlList:XMLList = xmlNode.attribute("url");
            if (urlList.length() > 0)
            loader.setSelectedURL(urlList[0].toString(),null);
            }
            }
            }


            ]]>
            </mx:Script>

            <mx:VBox x="0" y="0" percentWidth="100" percentHeight="100">
            <mx:HDividedBox
            horizontalAlign="left"
            percentWidth="100"
            percentHeight="100"
            backgroundColor="#FFFFFF">
            <mx:Panel title="PM Portal Menu" percentHeight="100">
            <pm:pmportal_menu
            id="leftMenu"
            width="195"
            fontWeight="bold"
            initialize="leftMenu.addEventListener('click', this.change);"
            borderThickness="0" />
            </mx:Panel>
            <mx:VBox
            id="apparea"
            percentHeight="100"
            percentWidth="100"
            paddingBottom="0"
            paddingLeft="0"
            paddingRight="0"
            paddingTop="0" >
            <common:application_loader id="loader" percentWidth="100" percentHeight="100"/>
            </mx:VBox>
            </mx:HDividedBox>
            </mx:VBox>

            </mx:Application>

            The ModuleLoader (A.K.A. applicationLoader):

            <?xml version="1.0" encoding="utf-8"?>
            <mx:ModuleLoader
            xmlns:mx=" http://www.adobe.com/2006/mxml"
            percentWidth="100"
            percentHeight="100" >

            <mx:Script>
            <![CDATA[

            [Bindable]
            private var selectedURL:String = "";
            private var param:Object = null;

            private function change(evt:Event):void
            {
            }

            private function getLoaderUrl(url:String):String
            {
            return url + ".swf";
            }

            public function setSelectedURL(url:String, p:Object):void
            {
            if (url != null)
            {
            this.selectedURL = getLoaderUrl(url);
            }

            if (p != null)
            {
            this.param = p;
            }
            this.url = this.selectedURL;
            }

            public function getParam():Object
            {
            return this.param;
            }

            public function resetParamList():void
            {
            param = null;
            }

            ]]>
            </mx:Script>
            </mx:ModuleLoader>

            --Andy
            • 3. Re: Big Fat Ugly Module Bug
              digitalentropy
              I too, am getting this error!

              My basic setup is this:

              Originally in my application, each screen was a separate component. With the inclusion of modules, I thought it would make sense to port them over. Hence, I have the following design:

              One ModuleLoader in my main application, which has the following:

              A custom menu and a viewstack. The menu allows the user to navigate the viewstack. Inside the viewstack are different modules, each representing a different screen of the application. The first two modules consist of a root panel and several child panels. They load just fine. The third, however, has a root panel and a TabNavigator inside. As soon as I load the third child, I get the following:

              TypeError: Error #1009: Cannot access a property or method of a null object reference.
              at mx.managers::HistoryManager$/register()
              at mx.containers::ViewStack/::addedHandler()
              at flash.display::DisplayObjectContainer/addChildAt()
              at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::$addChildAt()
              at mx.core::Container/addChildAt()
              at mx.core::Container/addChild()
              at mx.core::Container/createComponentFromDescriptor()
              at mx.core::Container/createComponentsFromDescriptors()
              at mx.containers::Panel/createComponentsFromDescriptors()
              at mx.core::Container/mx.core:Container::createChildren()
              at mx.containers::Panel/mx.containers:Panel::createChildren()
              at mx.core::UIComponent/initialize()
              at mx.core::Container/initialize()
              at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::childAdded()
              at mx.core::Container/ http://www.adobe.com/2006/flex/mx/internal::childAdded()
              at mx.core::Container/addChildAt()
              at mx.core::Container/addChild()
              at mx.core::Container/createComponentFromDescriptor()
              at mx.core::Container/createComponentsFromDescriptors()
              at mx.core::Container/mx.core:Container::createChildren()
              at mx.core::UIComponent/initialize()
              at mx.core::Container/initialize()
              at PrepareResearch/initialize()
              at mx.core::UIComponent/ http://www.adobe.com/2006/flex/mx/internal::childAdded()
              at mx.core::Container/ http://www.adobe.com/2006/flex/mx/internal::childAdded()
              at mx.core::Container/addChildAt()
              at mx.core::Container/addChild()
              at mx.modules::ModuleLoader/::moduleReadyHandler()
              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at ::ModuleInfoProxy/::moduleEventHandler()
              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at ::ModuleInfo/readyHandler()
              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at mx.core::FlexModuleFactory/::update()
              at mx.core::FlexModuleFactory/::docFrameHandler()

              The module seems to load fine after that, but it's pretty ugly. Unlike awclemen's problem, I get the error the first time the child is loaded. After that, I can navigate to a different child and back and get no error.

              I've tried some things like setting historyManagementEnabled = false, but from the documentation that looks like the default so I'm not sure what good it would do.

              Looking forward to a solution!
              • 4. Re: Big Fat Ugly Module Bug
                digitalentropy Level 1
                I have a sample of the issue online now:

                http://seanrea.net/ModuleTest/ModuleTest.html

                The two buttons control which child of the ViewStack is visible. If you click '2', it should pop up the HistoryManager error.

                Source for the project can be found here:

                seanrea.net/ModuleTest.rar

                Any ideas?
                • 5. Re: Big Fat Ugly Module Bug
                  digitalentropy Level 1
                  Seems to have been solved, or perhaps just bypassed.

                  There's a thread over at Flexcoders which helped me resolve it: http://tech.groups.yahoo.com/group/flexcoders/message/63448

                  In essence, adding the following function upon initialize in my shell solved the problem:

                  private function init():void
                  {
                  this.addChild(new TabNavigator());
                  this.removeChildAt(this.numChildren-1);
                  }

                  Hope this helps you.