7 Replies Latest reply on Jan 26, 2011 10:58 PM by Flex harUI

    A bug about Module

    moo213

      Recently I am reading the book "Adobe Flex 3: Training from the source". I ran the code in lesson 20 but got a error. Then I spent one day on picking up it.

       

      Then I found it and I wrote a simpler example.

       

       

       

      it seems that if the module is bigger than a size(actually not very big, just a form as you see in mymodule.mxml),  there will be an error(often nullpointer at some ui class). 

       

      But if the red line deleted, or the yellow line deleted(to cut the size of mymodule), the error will disappear.

       

       

      Actually I want to call the function  myinithello() when the module has complete loading,  but even though the function myinithello() has not been called(as the test.mxml) , the error will also appear.

       

       

       

       

      test.mxml:

       

      <?xml version="1.0"?>
      <s:Application
      xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx">

      <fx:Script>
        <![CDATA[   
        private function myinithello():void {
         m1.child as ChildModule1;
        }  
      ]]>
      </fx:Script>
      <mx:ModuleLoader url="mymodule.swf" id="m1"  />
      </s:Application>

       

       

       

       

       

      mymodule.mxml

      <?xml version="1.0"?>
      <mx:Module
      xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      width="100%" height="100%">


      <mx:VBox>
        <mx:Form>
         <mx:Label text="hello" />
         <mx:FormItem label="item1">
         </mx:FormItem>
         <mx:FormItem label="item2">
         </mx:FormItem>
        </mx:Form>
      </mx:VBox>

      </mx:Module>

       

       

       

       

      报错信息:

       

      TypeError: Error #1009: 无法访问空对象引用的属性或方法。
      at mx.core::UIComponent/getStyle()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UI Component.as:10372]
      at mx.core::UIComponent/getTextFieldClassName()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\core\UIComponent.as:11905]
      at mx.core::UIComponent/createInFontContext()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:11870]
      at mx.controls::Label/http://www.adobe.com/2006/flex/mx/internal::createTextField()[E:\dev\4.0.0\frameworks\proj ects\framework\src\mx\controls\Label.as:1506]
      at mx.controls::Label/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\con trols\Label.as:1319]
      at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\UIComponent.as:7142]
      at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3951]
      at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:2616]
      at mx.containers::Form/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\contai ners\Form.as:293]
      at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
      at mx.containers::Form/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\containe rs\Form.as:282]
      at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\core\Container.as:4371]
      at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\core\Container.as:4160]
      at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\Container.as:3187]
      at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
      at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:3129]
      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\UIComponent.as:7142]
      at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3951]
      at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:2616]
      at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
      at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\core\Container.as:4371]
      at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\core\Container.as:4160]
      at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\Container.as:3187]
      at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
      at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:3129]
      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\UIComponent.as:7142]
      at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3951]
      at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:2616]
      at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
      at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\core\Container.as:4371]
      at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\core\Container.as:4160]
      at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\Container.as:3187]
      at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\ UIComponent.as:7250]
      at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:3129]
      at ChildModule1/initialize()
      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\UIComponent.as:7142]
      at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3951]
      at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Co ntainer.as:2616]
      at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Cont ainer.as:2534]
      at mx.modules::ModuleLoader/moduleReadyHandler()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\modules\ModuleLoader.as:468]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\mo dules\ModuleManager.as:1168]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at ModuleInfo/readyHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\modules\Modul eManager.as:812]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::FlexModuleFactory/update()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\cor e\FlexModuleFactory.as:433]
      at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\core\FlexModuleFactory.as:582]
      at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\core\FlexModuleFactory.as:126]

        • 1. Re: A bug about Module
          Gaurav J Adobe Employee

          Your example does not compile. Post the complete test case that is giving the RTE.

           

          -Gaurav

          http://www.gauravj.com/blog

          • 2. Re: A bug about Module
            moo213 Level 1

            red line in test.mxml:    m1.child as ChildModule1;

             

            Yellow line in mymodule.mxml:   <mx:Label text="hello" />

             

            test.mxml:

             

            <?xml version="1.0"?>
            <s:Application
            xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx">

            <fx:Script>
              <![CDATA[   
              private function myinithello():void {
              m1.child as ChildModule1;
              }  
            ]]>
            </fx:Script>
            <mx:ModuleLoader url="mymodule.swf" id="m1"  />
            </s:Application>

             

             

              

             

             

            mymodule.mxml

            <?xml version="1.0"?>
            <mx:Module
            xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            width="100%" height="100%">


            <mx:VBox>
              <mx:Form>
              <mx:Label text="hello" />
               <mx:FormItem label="item1">
               </mx:FormItem>
               <mx:FormItem label="item2">
               </mx:FormItem>
              </mx:Form>
            </mx:VBox>

             

            </mx:Module>

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            TypeError: Error #1009: Cannot access a property or method of a null object reference

            at mx.core::UIComponent/getStyle()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\UIComponent.as:10372]
            at mx.core::UIComponent/getTextFieldClassName()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\UIComponent.as:11905]
            at mx.core::UIComponent/createInFontContext()[E:\dev\4.0.0\frameworks\pr ojects\framework\src\mx\core\UIComponent.as:11870]
            at mx.controls::Label/http://www.adobe.com/2006/flex/mx/internal::createTextField()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\controls\Label.as :1506]
            at mx.controls::Label/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\controls\Label.as:1319]
            at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
            at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
            at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
            at mx.containers::Form/addChildAt()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\containers\Form.as:293]
            at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
            at mx.containers::Form/addChild()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\containers\Form.as:282]
            at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
            at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
            at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
            at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
            at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
            at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
            at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
            at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
            at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
            at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
            at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
            at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
            at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
            at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
            at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
            at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
            at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
            at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
            at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
            at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
            at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
            at ChildModule1/initialize()
            at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
            at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
            at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
            at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
            at mx.modules::ModuleLoader/moduleReadyHandler()[E:\dev\4.0.0\frameworks \projects\framework\src\mx\modules\ModuleLoader.as:468]
            at flash.events::EventDispatcher/dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.0.0\frameworks\projects \framework\src\mx\modules\ModuleManager.as:1168]
            at flash.events::EventDispatcher/dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at ModuleInfo/readyHandler()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\modules\ModuleManager.as:812]
            at flash.events::EventDispatcher/dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at mx.core::FlexModuleFactory/update()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\FlexModuleFactory.as:433]
            at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\FlexModuleFactory.as:582]
            at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.0.0\frameworks \projects\framework\src\mx\core\FlexModuleFactory.as:126]

            • 3. Re: A bug about Module
              Flex harUI Adobe Employee

              You are using the ChildModule1 class in the main application.  This links

              ChildModule1 into the main app which defeats the purpose of modules and

              causes style calculation errors.  Use an interface to talk to the module

              from the main app.

              • 4. Re: A bug about Module
                moo213 Level 1

                sorry, "ChildModule"->"MyModule"

                 

                The code was modifeid from the first example of "Accessing modules from the parent application" in http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf64277-7fea.html

                 

                i just add a form to the module..

                 

                 

                 

                 

                red line in test.mxml:    m1.child as MyModule;

                 

                Yellow line in MyModule.mxml:   <mx:Label text="hello" />

                 

                test.mxml:

                 

                <?xml version="1.0"?>
                <s:Application
                xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx">

                <fx:Script>
                  <![CDATA[   
                  private function myinithello():void {
                  m1.child as MyModule;
                  }  
                ]]>
                </fx:Script>
                <mx:ModuleLoader url="MyModule.swf" id="m1"  />
                </s:Application>

                 

                 

                  

                 

                 

                MyModule.mxml

                <?xml version="1.0"?>
                <mx:Module
                xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                width="100%" height="100%">


                <mx:VBox>
                  <mx:Form>
                  <mx:Label text="hello" />
                   <mx:FormItem label="item1">
                   </mx:FormItem>
                   <mx:FormItem label="item2">
                   </mx:FormItem>
                  </mx:Form>
                </mx:VBox>

                 

                </mx:Module>

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                TypeError: Error #1009: Cannot access a property or method of a null object reference

                at mx.core::UIComponent/getStyle()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\UIComponent.as:10372]
                at mx.core::UIComponent/getTextFieldClassName()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\UIComponent.as:11905]
                at mx.core::UIComponent/createInFontContext()[E:\dev\4.0.0\frameworks\pr ojects\framework\src\mx\core\UIComponent.as:11870]
                at mx.controls::Label/http://www.adobe.com/2006/flex/mx/internal::createTextField()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\controls\Label.as :1506]
                at mx.controls::Label/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\controls\Label.as:1319]
                at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
                at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
                at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
                at mx.containers::Form/addChildAt()[E:\dev\4.0.0\frameworks\projects\fra mework\src\mx\containers\Form.as:293]
                at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
                at mx.containers::Form/addChild()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\containers\Form.as:282]
                at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
                at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
                at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
                at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
                at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
                at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
                at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
                at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
                at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
                at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
                at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
                at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
                at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
                at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
                at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
                at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
                at mx.core::Container/createComponentFromDescriptor()[E:\dev\4.0.0\frame works\projects\framework\src\mx\core\Container.as:4371]
                at mx.core::Container/createComponentsFromDescriptors()[E:\dev\4.0.0\fra meworks\projects\framework\src\mx\core\Container.as:4160]
                at mx.core::Container/createChildren()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\Container.as:3187]
                at mx.core::UIComponent/initialize()[E:\dev\4.0.0\frameworks\projects\fr amework\src\mx\core\UIComponent.as:7250]
                at mx.core::Container/initialize()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:3129]
                at ChildModule1/initialize()
                at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent. as:7142]
                at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\Container.as :3951]
                at mx.core::Container/addChildAt()[E:\dev\4.0.0\frameworks\projects\fram ework\src\mx\core\Container.as:2616]
                at mx.core::Container/addChild()[E:\dev\4.0.0\frameworks\projects\framew ork\src\mx\core\Container.as:2534]
                at mx.modules::ModuleLoader/moduleReadyHandler()[E:\dev\4.0.0\frameworks \projects\framework\src\mx\modules\ModuleLoader.as:468]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.0.0\frameworks\projects \framework\src\mx\modules\ModuleManager.as:1168]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at ModuleInfo/readyHandler()[E:\dev\4.0.0\frameworks\projects\framework\ src\mx\modules\ModuleManager.as:812]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at mx.core::FlexModuleFactory/update()[E:\dev\4.0.0\frameworks\projects\ framework\src\mx\core\FlexModuleFactory.as:433]
                at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.0.0\frameworks\ projects\framework\src\mx\core\FlexModuleFactory.as:582]
                at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.0.0\frameworks \projects\framework\src\mx\core\FlexModuleFactory.as:126]

                 

                 

                 

                 

                 

                 

                • 5. Re: A bug about Module
                  moo213 Level 1

                  I think that add a interface can solve the problem. It seems that the cast "m1.child as MyModule" cause memory leak. But the segment has never run and the function has never been called.  Why?

                  • 6. Re: A bug about Module
                    Gaurav J Adobe Employee

                    you didn't call it.

                     

                    You should attach a ready event handler to your moduleLoader. Something like:

                     

                    <mx:ModuleLoader url="mymodule.swf" id="m1"  ready="readyHandler(event)"/>

                     

                    and

                     

                    import mx.events.ModuleEvent;

                     

                    private function myinithello(e:ModuleEvent):void {
                       m1.child as ChildModule1;
                      } 

                     

                    -Gaurav

                    http://www.gauravj.com/blog

                    • 7. Re: A bug about Module
                      Flex harUI Adobe Employee

                      I don't think it will cause a memory leak, but it will cause the exception

                      you are describing.  The doc example correctly uses an interface.  You are

                      not.  You can find several past threads on this forum where folks had the

                      same problem.  The code does not have to run to cause linking issues that

                      result in the exception.