21 Replies Latest reply on Aug 13, 2010 2:12 AM by showping.tong

    Module Loading Problem

    msc_santu Level 1

      Hi,

       

      I am facing problem with Module Loading.  In my application i have 5 modules.  On loading of each module i need to get data from the Database and populate that data in the frontend.  In some modules i am using DataGrid to populate that data.  In some modules i am using ComboBoxes to populate the data.

       

      Module which is loaded for the first time, will execute without any errors.

      As part of module loader in my application, i am removing all childs and then i am unloading existing module before loading new module.

       

      if a module is already loaded and if i want to load another module, i am getting errors.  Please help......

       

      TypeError: Error #1007: Instantiation attempted on a non-constructor.
      at mx.controls.dataGridClasses::DataGridHeader/updateDisplayList()[C:\autobuild\3.2.0\framew orks\projects\framework\src\mx\controls\dataGridClasses\DataGridHeader.as:242]
      at mx.core::UIComponent/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:6351]
      at mx.managers::LayoutManager/validateClient()[C:\autobuild\3.2.0\frameworks\projects\framew ork\src\mx\managers\LayoutManager.as:880]
      at mx.core::UIComponent/validateNow()[C:\autobuild\3.2.0\frameworks\projects\framework\src\m x\core\UIComponent.as:5679]
      at mx.controls.dataGridClasses::DataGridBase/updateDisplayList()[C:\autobuild\3.2.0\framewor ks\projects\framework\src\mx\controls\dataGridClasses\DataGridBase.as:493]
      at mx.controls::DataGrid/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framewor k\src\mx\controls\DataGrid.as:1437]
      at mx.controls.listClasses::ListBase/validateDisplayList()[C:\autobuild\3.2.0\frameworks\pro jects\framework\src\mx\controls\listClasses\ListBase.as:3280]
      at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\f ramework\src\mx\managers\LayoutManager.as:622]
      at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects \framework\src\mx\managers\LayoutManager.as:695]
      at Function/http://adobe.com/AS3/2006/builtin::apply()

        • 1. Re: Module Loading Problem
          Flex harUI Adobe Employee

          That's the shared-code problem described in the modules presentation on my blog.  One way folks get around that is to load the styles for DataGrid as a CSS module into the same applicationdomain as the main app.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          1 person found this helpful
          • 2. Re: Module Loading Problem
            msc_santu Level 1

            Hi Harui,

             

            Thank you very much for your response.  Currently i am loading styles into my Application using using

            <mx:Style

             

            source="/assets/styles/main.css" />.

            I am loading the Styles in my main Application i.e. MainApp.mxml file.

            But you are talking about loading CSS Module.  Can you please explain or give any link related to CSS Module.

             

            Waiting for your reply.

             

            Cheers,

            Santu

            • 3. Re: Module Loading Problem
              Flex harUI Adobe Employee

              Should be in the documentation as loadStyleDeclarations()

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: Module Loading Problem
                msc_santu Level 1

                Hi Alex Harui,

                 

                Type 1 Solution:

                 

                I removed all styles in my application.  Still i am getting the same error. i.e. "Error #1007: Instantiation attempted on a non-constructor."    My entire projects completely depends on Modules.

                 

                As i didn't succedded with Type 1 Solution, i tried the below way.  But still i didn't succeeded.

                 

                Type 2 Solution:

                 

                StyleManager.loadStyleDeclarations(

                 

                "assets/styles/main.swf",true,false, ApplicationDomain.currentDomain);

                 

                var m:IModuleInfo = ModuleManager.getModule("com/psk/common/SharedCode.swf");

                m.load(ApplicationDomain.currentDomain);

                 

                Kindly guide me how to resolve this error as i didn't succeeded with Type 1 solution or Type 2 solution.

                 

                Regards,

                Santhosh

                • 5. Re: Module Loading Problem
                  Flex harUI Adobe Employee

                  The DataGrid is looking for the style "headerBackgroundSkin".  Make sure it

                  is getting loaded.  Use link-report to see what is in each of your SWFs

                  • 6. Re: Module Loading Problem
                    showping.tong

                    hi,Alex

                     

                    I always got the problems in my Application!

                     

                    In the main app ,I load css module use StyleManager.loadStyleDeclarations("css.swf",true,false,ApplicationDomain.currentDomain);

                     

                    And Module loading use ModuleManager to load ModuleInfo.

                    In ModuleInfo use moduleInfo.load(ApplicationDomain.currentDomain);

                     

                    But also can't resolve the problem!

                     

                    SO I visited you blog to find the resolve method,But I can't find it!

                    please tell me the URL you said that share-code problem.

                     

                    Or directly tell me how to resolve my problem!

                     

                    Thanks!

                     

                    Best regards

                    • 7. Re: Module Loading Problem
                      Flex harUI Adobe Employee

                      It should be in the sample code for this post:

                      http://blogs.adobe.com/aharui/2007/03/modules.html

                      • 8. Re: Module Loading Problem
                        showping.tong Level 1

                        hi,Alex:

                         

                        Yesterday,I wirte headerBackgroundSkin and headerSeparatorSkin CSS in my css file.

                        Then the Error had been reslove.

                         

                        But I move my cursor to the DataGrid component header today ,It appear the 1007 again.like follow:

                        TypeError: Error #1007:
                            at mx.managers::CursorManagerImpl/showCurrentCursor()
                            at mx.managers::CursorManagerImpl/setCursor()
                            at mx.controls.dataGridClasses::DataGridHeader/columnResizeMouseOverHandler()

                         

                        SO I think there must have other CSS should be added to CSS file;

                         

                        And I check the Adobe Help,Can't find the DataGrid which had defined the Cursor CSS or any more!

                         

                        Can you tell me all the DataGrid compoonent CSS list?

                         

                        Thanks!

                         

                        Best Regards!

                        • 9. Re: Module Loading Problem
                          Flex harUI Adobe Employee

                          You can find it in defaults.css in frameworks/projects/framework

                          • 10. Re: Module Loading Problem
                            showping.tong Level 1

                            hi,Alex:

                             

                            Thanks for your help!

                            I got all Datagrid CSS from default.css file.and The Errors of Datagrid Component had all been resolved!

                             

                            But There is another problem.

                             

                            I use moduleInfo.factory.create() to loose weight for module.

                            But the module size is over 100k always.

                            I profiled in FlashBuilder. if get the module 2 or more times,I Check from the memory there have 2 or more instance.

                             

                            That,I think the moduleInfo.factory.create() method is not the perfect method.

                             

                            SO ,Can you tell me how to loose weight for modules?

                            and reduce the instance number in the memory?

                             

                            Thanks.

                             

                            Best regards!

                            • 11. Re: Module Loading Problem
                              Flex harUI Adobe Employee

                              Read all the module posts on my blog.

                              • 12. Re: Module Loading Problem
                                showping.tong Level 1

                                hi,Alex:

                                 

                                Thanks for your reply!

                                 

                                I just found some rules on your blog,

                                 

                                One is setTimeout() must have clearTimeout() to make a pair.

                                 

                                But In my code,I didn't know to clearTimeout(),My code follow:

                                 

                                public class PLModuleFactoryBase extends Sprite implements IFlexModuleFactory
                                    {
                                        protected var moduleInstance:PLModuleBase;
                                       
                                        public function PLModuleFactoryBase()
                                        {
                                            super(); 
                                            setTimeout(function():void{
                                                dispatchEvent(new Event("ready")); 
                                            },0);
                                        } 
                                       
                                        public function create(...args):Object 
                                        {
                                            if(!moduleInstance)
                                                moduleInstance=new PLModuleBase();
                                            return moduleInstance;
                                        } 
                                       
                                       
                                        public function info():Object 
                                        { 
                                            return {currentDomain:ApplicationDomain.currentDomain}; 
                                        }

                                }

                                 

                                In the coustructor there is a setTimeout.Means is dispatch a Event when the module has loaded.

                                 

                                What can I do that clearTimeout when the module has loaded?

                                 

                                Thanks!

                                 

                                Best Regards!

                                 

                                Showping.tong

                                • 13. Re: Module Loading Problem
                                  Flex harUI Adobe Employee

                                  public function PLModuleFactoryBase()

                                  {

                                     super(); 

                                     var timeoutID:* = setTimeout(function():void{

                                                  dispatchEvent(new Event("ready")); 

                                                  clearTimeout(timeoutID);

                                              },0);

                                  • 14. Re: Module Loading Problem
                                    showping.tong Level 1

                                    hi,Alex:

                                     

                                    The sentence of you provide don't mak effect in my Application.

                                     

                                    The instance number of the module do not reduce.

                                     

                                    Thanks also.

                                     

                                    Best regards

                                    • 15. Re: Module Loading Problem
                                      Flex harUI Adobe Employee

                                      Use the profiler to see if there are other references to things in your

                                      module

                                      • 16. Re: Module Loading Problem
                                        showping.tong Level 1

                                        hi,Alex:

                                         

                                        Thanks for your reply!

                                         

                                        I can't know how to  see if there are other references to things in my module using profiler.

                                         

                                        The profile Provide only limited functionality to let user know how many instance in the memory.

                                         

                                        Can you tell how to see?

                                         

                                        Thanks!

                                         

                                        Best Regards!

                                        • 17. Re: Module Loading Problem
                                          Flex harUI Adobe Employee

                                          See the profiler posts on my blog.

                                           

                                          --

                                          Alex Harui

                                          Flex SDK Team

                                          Adobe System, Inc.

                                          http://blogs.adobe.com/aharui

                                          • 18. Re: Module Loading Problem
                                            showping.tong Level 1

                                            hi,Alex:

                                             

                                            Thanks for your reply!

                                             

                                            I had resove the before problem.

                                             

                                            But I got another problem.

                                             

                                            In My Application ,I extend a TitleWindow Component in a mxml file named PLWindow.

                                            When I put it in my Main application or module,I found I can't change it's width or height.

                                            But I put TitleWindow Component to application ,It can change width and height.

                                            My Flex SDK version is 3.5.

                                             

                                            So,Can you tell me how to extend a TitleWindow component that can change width and height.

                                             

                                            Thanks!

                                             

                                            Best Regards!

                                            • 19. Re: Module Loading Problem
                                              Flex harUI Adobe Employee

                                              You should be able to change its size by setting its width and height

                                              properties.  If that isn't working, make a small test case and post it.

                                              • 20. Re: Module Loading Problem
                                                showping.tong Level 1

                                                hi,Alex:

                                                 

                                                I write code Your guidance under,Just follow:

                                                override public function set width(value:Number):void
                                                            {
                                                                super.width=value;
                                                            }
                                                            override public function set height(value:Number):void
                                                            {
                                                                super.height=value;
                                                            }

                                                 

                                                Another,I need to Descript clear.

                                                I use StyleManager.loadStyleDeclarations(StaticURL.cssDoc,true,false,ApplicationDomain.currentD omain);

                                                That load css module swf.

                                                 

                                                And I test my custom component in myApplication,It did not show scale the skin.

                                                But in the same time,I use TitleWindow Component ,It show the scale the skin.

                                                 

                                                So,I think It may be the extands problem,Why directly use the TitleWindow,I don't have Problem.and Use the TitleWindow by extanding.

                                                The problem had been?

                                                 

                                                It maybe a bug in FlashBuilder?

                                                 

                                                Thanks!

                                                 

                                                Best Regards!

                                                • 21. Re: Module Loading Problem
                                                  showping.tong Level 1

                                                  Sorry,Alex:

                                                   

                                                  I had resolved the problem.

                                                   

                                                  Beacuse I Override the layoutChrome Method in my Custom Title.But dit not super.layoutChrome()

                                                   

                                                  Thanks also

                                                   

                                                  Regards!