33 Replies Latest reply: May 31, 2013 1:22 PM by SashandMiMi RSS

    Flex 4.6 unable load module, if it contains a chart component.

    niranjan swain Community Member

      Hi All,

       

      I am facing a problem in 4.6 flex SDK however it is working fine in earlier version sdks.

      I used a column chart in a module and tried to load the module in flex 4.6 Application . It gives the following error.

       

      12/27/2011-18:17:29.625-[ FATAL ] 1009 - Error #1009: Cannot access a property or method of a null object reference.

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

      at mx.charts.chartClasses::ChartBase/initStyles()

      at mx.charts.chartClasses::ChartBase/set moduleFactory()

      at mx.charts.chartClasses::CartesianChart/set moduleFactory()

      at mx.charts::ColumnChart/set moduleFactory()

      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()

      at spark.components::Group/setMXMLContent()

      at spark.components::Group/set mxmlContent()

      at spark.components::SkinnableContainer/set mxmlContent()

      at spark.components::SkinnableContainer/createDeferredContent()

      at mx.containers::ViewStack/instantiateSelectedChild()

      at mx.containers::ViewStack/commitProperties()

      at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx \core\UIComponent.as:8219]

      at mx.managers::LayoutManager/validateClient()[E:\dev\4.y\frameworks\projects\framework\src\ mx\managers\LayoutManager.as:957]

      at mx.managers::PopUpManagerImpl/addPopUp()

      at mx.managers::PopUpManager$/addPopUp()

       

      Thanks in Advance

      Niranjan Swain

        • 1. Re: Flex 4.6 unable load module, if it contains a chart component.
          saisri2k2 Community Member

          Could you post the code here, something to do with the casting of the module that is loaded.

          • 2. Re: Flex 4.6 unable load module, if it contains a chart component.
            kmwill23 Community Member

            I am also experiencing this same error after upgrading to FlashBuilder 4.6.

             

            When I run the .swf as a separate application, it works just fine  When I embed it within another swf application, that is when the error occurs.  Here is the code which, when commented out, removes the error.  No failure in the swf itself, just in the SWFLoader.

             

             






            <s:Panel styleName="grayBack" id="chartDisplay" height="200" width="100%" backgroundColor="#ffffff">













            <mx:SWFLoader id="graphs" source="graphs.swf" height="100%" width="100%"/>






            <s:Button id="popoutButton" click="PopoutGraph(event)" right="3" top="3" toolTip="Expand Graphs"/>












            </s:Panel>

             

             

            Not sure how this will post, there is no 'code' tag selectable.

            • 3. Re: Flex 4.6 unable load module, if it contains a chart component.
              Flex harUI Adobe Employee

              What stack trace are you getting?  You may have to use the module’s moduleFactory in the params to PopUpManager APIs.

              • 4. Re: Flex 4.6 unable load module, if it contains a chart component.
                kmwill23 Community Member

                It is the exact stack trace of the original poster.

                • 5. Re: Flex 4.6 unable load module, if it contains a chart component.
                  kmwill23 Community Member

                  The crash is occurring here in ChartBase.as

                   

                  private function initStyles():Boolean

                  {

                      HaloDefaults.init(styleManager);

                   

                                      var chartBaseStyle:CSSStyleDeclaration = styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase");

                                      chartBaseStyle.setStyle("chartSeriesStyles", HaloDefaults.chartBaseChartSeriesStyles); <<<<<<<<<<<  Occurs here.  chartBaseStyle is null.

                                      chartBaseStyle.setStyle("fill", new SolidColor(0xFFFFFF, 0));

                                      chartBaseStyle.setStyle("calloutStroke", new SolidColorStroke(0x888888,2));

                   

                      return true;

                  }

                  • 6. Re: Flex 4.6 unable load module, if it contains a chart component.
                    Flex harUI Adobe Employee

                    If you are using PopUpManager, try using the moduleFactory parameter.

                    • 7. Re: Flex 4.6 unable load module, if it contains a chart component.
                      kmwill23 Community Member

                      Not using PopUpManager.   The PopOut function does not use this, it opens the application in a new browser window.  And it works if I comment out the SWLoader.

                       

                      The error occurs at loadtime, not as a result of firing any UI events.

                      • 8. Re: Flex 4.6 unable load module, if it contains a chart component.
                        Flex harUI Adobe Employee

                        The OP’s stacktrace included PopUpManager.  You claimed yours is the same.  Is it or isn’t it?  If it isn’t, post the stack trace.  If it is, then use the moduleFactory parameter on PopUpManager.

                        • 9. Re: Flex 4.6 unable load module, if it contains a chart component.
                          kmwill23 Community Member

                          Ah ha!  Caught me.  I will be back in a few hours to post it, I just shut down my VM.  I can tell you that instead of the two PopUpManager lines, I have two Layoutmanager lines.

                           

                          Details in a few hours, though I know you might not respond until tomorrow.  Thanks for being so avaiable to answer questions!

                          • 10. Re: Flex 4.6 unable load module, if it contains a chart component.
                            kmwill23 Community Member

                            Trace:

                             

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

                                      at mx.charts.chartClasses::ChartBase/initStyles()[E:\dev\4.y\frameworks\projects\charts\src\ mx\charts\chartClasses\ChartBase.as:1862]

                                      at mx.charts.chartClasses::ChartBase/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\chartClasses\ChartBas e.as:1894]

                                      at mx.charts.chartClasses::CartesianChart/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\chartClasses\Cartesia nChart.as:816]

                                      at mx.charts::LineChart/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\LineChart.as:191]

                                      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1590]

                                      at spark.components::Group/setMXMLContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:633]

                                      at spark.components::Group/createChildren()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:855]

                                      at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7634]

                                      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]

                                      at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7199]

                                      at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\Group.as:2037]

                                      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]

                                      at spark.components::Group/addElementAt()[E:\dev\4.y\frameworks\projects\spark\src\spark\com ponents\Group.as:1387]

                                      at mx.states::AddItems/addItemsToContentHolder()[E:\dev\4.y\frameworks\projects\framework\sr c\mx\states\AddItems.as:782]

                                      at mx.states::AddItems/apply()[E:\dev\4.y\frameworks\projects\framework\src\mx\states\AddIte ms.as:563]

                                      at mx.core::UIComponent/applyState()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:10741]

                                      at mx.core::UIComponent/commitCurrentState()[E:\dev\4.y\frameworks\projects\framework\src\mx \core\UIComponent.as:10487]

                                      at mx.core::UIComponent/commitProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx\c ore\UIComponent.as:8304]

                                      at spark.components.supportClasses::SkinnableComponent/commitProperties()[E:\dev\4.y\framewo rks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:452]

                                      at spark.components::Application/commitProperties()[E:\dev\4.y\frameworks\projects\spark\src \spark\components\Application.as:1532]

                                      at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx \core\UIComponent.as:8219]

                                      at mx.managers::LayoutManager/validateProperties()[E:\dev\4.y\frameworks\projects\framework\ src\mx\managers\LayoutManager.as:597]

                                      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:783]

                                      at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects \framework\src\mx\managers\LayoutManager.as:1180]

                             

                            Okay, it has a few key differences.  Thanks for calling me on that.

                            • 11. Re: Flex 4.6 unable load module, if it contains a chart component.
                              Flex harUI Adobe Employee

                              Check the value of the moduleFactory.  It should be the SWF that contains the Chart (and its styles).  If it isn’t, how is the Chart being instantiated and parented?

                              • 12. Re: Flex 4.6 unable load module, if it contains a chart component.
                                kmwill23 Community Member

                                The moduel factory is...

                                 

                                "moduleFactory"_Graphs_mx_managers_SystemManager (@72620a1)
                                • 13. Re: Flex 4.6 unable load module, if it contains a chart component.
                                  Flex harUI Adobe Employee

                                  Can you post a small test case?  Use “code” in curly braces like wiki markup around your code.

                                  • 15. Re: Flex 4.6 unable load module, if it contains a chart component.
                                    Flex harUI Adobe Employee

                                    Yes, small is required so we know you’ve eliminated other things that could have side effects.  Have you tried a new project with nothing in the app and only the chart with no data in a module?

                                    • 16. Re: Flex 4.6 unable load module, if it contains a chart component.
                                      kmwill23 Community Member

                                      Okay, I have more details now.

                                       

                                      I created a new application as requested and placed the SWFLoader link within and it worked.  So I started playing around with our main application to try and find a setting that may have been conflicting.

                                       

                                      I discovered something interesting.  Within the main application we have 6 other LineCharts.  Since that was the only thing I could find that was related, yet different from running the application in the Test Case, I tried commenting all our graphs out.

                                       

                                      It ran successfully.

                                       

                                      Does this help at all?  I am going to keep poking around nd try to find why an internally run application with graphs would crash if the main application has graphs.  The disturbing part, however, is that this all works fine in FlashBuilder 4.5.

                                      • 17. Re: Flex 4.6 unable load module, if it contains a chart component.
                                        kmwill23 Community Member

                                        This crashes, new test case.

                                         

                                        {code}

                                         

                                        <?xml version="1.0" encoding="utf-8"?>

                                        <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" minWidth="200" minHeight="200"

                                                                         xmlns:ns="library://ns.ntorus.com/common"

                                                                         >

                                                  <s:layout>

                                                            <s:VerticalLayout paddingTop="8" paddingRight="12" paddingBottom="0" paddingLeft="12"/>

                                                  </s:layout>

                                                  <fx:Declarations>

                                                  </fx:Declarations>

                                                  <s:BorderContainer width="20" height="16" toolTip="Trend lines">

                                                            <mx:LineChart id="sparkGraph1" width="18" height="14">

                                                                      <mx:seriesFilters>

                                                                                <fx:Array/>

                                                                      </mx:seriesFilters>

                                                                      <mx:horizontalAxis>

                                                                                <mx:CategoryAxis id="xAxis1" categoryField="Period"/>

                                                                      </mx:horizontalAxis>

                                                                      <mx:horizontalAxisRenderers>

                                                                                <mx:AxisRenderer axis="{xAxis1}"

                                                                                                                         minorTickPlacement="none"

                                                                                                                         tickPlacement="none"

                                                                                                                         labelGap="0"

                                                                                                                         showLabels="false"

                                                                                                                         showLine="false"/>

                                                                      </mx:horizontalAxisRenderers>

                                                                      <mx:verticalAxis>

                                                                                <mx:LinearAxis id="yAxis1"/>

                                                                      </mx:verticalAxis>

                                                                      <mx:verticalAxisRenderers>

                                                                                <mx:AxisRenderer axis="{yAxis1}"

                                                                                                                         minorTickPlacement="none"

                                                                                                                         tickPlacement="none"

                                                                                                                         labelGap="0"

                                                                                                                         showLabels="false"

                                                                                                                         showLine="false" />

                                                                      </mx:verticalAxisRenderers>

                                                                      <mx:series>

                                                                                <mx:LineSeries yField="Data" stroke="{stroke1}">

                                                                                          <mx:lineStroke>

                                                                                                    <mx:SolidColorStroke id="stroke1" color="#1a5b8b" weight="1"/>

                                                                                          </mx:lineStroke>

                                                                                </mx:LineSeries>

                                                                      </mx:series>

                                                                      <mx:backgroundElements/>

                                                            </mx:LineChart>

                                                  </s:BorderContainer>

                                                  <ns:LoadingContainer id="loadingContainer" width="100%" height="100%">

                                                  <s:VGroup width="100%" height="100%" visible="true">

                                                  <s:Panel id="chartDisplay" height="200" width="100%" backgroundColor="#111111">

                                         

                                                            <mx:SWFLoader id="charts" source="Graphs.swf" height="100%" width="100%"/>

                                         

                                                  </s:Panel>

                                                  </s:VGroup>

                                                  </ns:LoadingContainer>

                                        </s:Application>

                                         

                                         

                                        {/code}

                                        • 18. Re: Flex 4.6 unable load module, if it contains a chart component.
                                          luciano.bustos Community Member

                                          We realize that overriding the get moduleFactory method. Works.

                                          /**  override this method on your module loaded byt the main app **/

                                          override public function get moduleFactory():IFlexModuleFactory {

                                                                                  return FlexGlobals.topLevelApplication.moduleFactory;

                                          }

                                           

                                          Becasue this line of code (  var chartBaseStyle:CSSStyleDeclaration = styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase");  ) is not able to find the rigth styleManager inherited styles.

                                          • 19. Re: Flex 4.6 unable load module, if it contains a chart component.
                                            kmwill23 Community Member

                                            Okay, have two errors for you.  Note that we run this app as both an internal and external app.

                                             

                                            First error, as an internal swf using SWFLoader.

                                             

                                            Error: Skin for GraphTest.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.loadingContainer.Skinnabl eContainerSkin23.contentGroup.VGroup25.chartDisplay.PanelSkin27._PanelSkin_Group1.contents .contentGroup.performanceCharts.FlexLoader36.instance49.Graphs42.ApplicationSkin43._Applic ationSkin_Group1.contentGroup.VGroup46.HGroup47.ddlGraphChoice cannot be found.

                                                      at spark.components.supportClasses::SkinnableComponent/attachSkin()[E:\dev\4.y\frameworks\pr ojects\spark\src\spark\components\supportClasses\SkinnableComponent.as:698]

                                                      at spark.components.supportClasses::SkinnableComponent/validateSkinChange()[E:\dev\4.y\frame works\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:443]

                                                      at spark.components.supportClasses::SkinnableComponent/createChildren()[E:\dev\4.y\framework s\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:406]

                                                      at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7634]

                                                      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]

                                                      at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7199]

                                                      at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\Group.as:2037]

                                                      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]

                                                      at spark.components::Group/setMXMLContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:633]

                                                      at spark.components::Group/createChildren()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:855]

                                                      at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7634]

                                                      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]

                                                      at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7199]

                                                      at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\Group.as:2037]

                                                      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]

                                                      at spark.components::Group/setMXMLContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:633]

                                                      at spark.components::Group/createChildren()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:855]

                                                      at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7634]

                                                      at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]

                                                      at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7199]

                                                      at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\Group.as:2037]

                                                      at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]

                                                      at spark.components::Group/setMXMLContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\c omponents\Group.as:633]

                                                      at spark.components::Group/set mxmlContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:573]

                                                      at spark.components::SkinnableContainer/set mxmlContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnableContaine r.as:657]

                                                      at spark.components::SkinnableContainer/createDeferredContent()[E:\dev\4.y\frameworks\projec ts\spark\src\spark\components\SkinnableContainer.as:1050]

                                                      at spark.components::SkinnableContainer/createContentIfNeeded()[E:\dev\4.y\frameworks\projec ts\spark\src\spark\components\SkinnableContainer.as:1078]

                                                      at spark.components::SkinnableContainer/createChildren()[E:\dev\4.y\frameworks\projects\spar k\src\spark\components\SkinnableContainer.as:885]

                                                      at spark.components::Application/createChildren()[E:\dev\4.y\frameworks\projects\spark\src\s park\components\Application.as:1504]

                                                      at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UI Component.as:7634]

                                                      at spark.components::Application/initialize()[E:\dev\4.y\frameworks\projects\spark\src\spark \components\Application.as:1355]

                                                      at Graphs/initialize()

                                                      at mx.managers.systemClasses::ChildManager/childAdded()[E:\dev\4.y\frameworks\projects\frame work\src\mx\managers\systemClasses\ChildManager.as:189]

                                                      at mx.managers.systemClasses::ChildManager/initializeTopLevelWindow()[E:\dev\4.y\frameworks\ projects\framework\src\mx\managers\systemClasses\ChildManager.as:359]

                                                      at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\managers\SystemManager.as:3057]

                                                      at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2843]

                                                      at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2723]

                                                      at flash.events::EventDispatcher/dispatchEventFunction()

                                                      at flash.events::EventDispatcher/dispatchEvent()

                                                      at mx.preloaders::Preloader/timerHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\p reloaders\Preloader.as:542]

                                                      at flash.utils::Timer/_timerDispatch()

                                                      at flash.utils::Timer/tick()

                                             

                                            ~~~~~~

                                             

                                            And second error is an infinite loop when running the application on its own.  This is using the override you gave me.

                                             

                                            Error: Error #1023: Stack overflow occurred.

                                                      at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                                      at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                                      at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                              at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                              at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                              at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                              at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                              at Graphs/get moduleFactory()[C:\SVN\Graphs.mxml:10]

                                            .... and on forever.

                                            • 20. Re: Flex 4.6 unable load module, if it contains a chart component.
                                              luciano.bustos Community Member

                                              Actually is working for me.

                                               

                                              My module proyect configuration

                                               

                                              flexmoduleconfig.PNG

                                              • 21. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                kmwill23 Community Member

                                                Okay, back from a nice weekend!

                                                 

                                                Any resolution yet?  While it looks like your office had some fun with the issue, I don't see a working solution for this 'unintended feature' of Flex 4.6.  Your project configuration really doesn't help me =)

                                                • 22. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                  luciano.bustos Community Member

                                                  We'll I don't know how to explain this.

                                                  Please share with me your test case project and I'll try to find a solution.

                                                  The 4.6 SDK seems to be a unestable.

                                                  • 23. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                    kmwill23 Community Member

                                                    4 posts up is my test case.  The only difference is that I added this code to my external swf:

                                                     

                                                    override public function get moduleFactory():IFlexModuleFactory

                                                    {

                                                        return FlexGlobals.topLevelApplication.moduleFactory;

                                                    }

                                                     

                                                    I cannot post the external swf code.

                                                     

                                                    Summary of issue so far:

                                                     

                                                    - When you have a flex project with ChartBase elements and attempt to imbed by SWFLoader another flex project with ChartBase elements, the imbedded swf will fail in a null exception when attempting to load the ChartBase styles.

                                                     

                                                    - This was not an issue in Flex 4.5

                                                     

                                                    - Removing all ChartBase elements from the host application allows the imbedded application to work perfectly.  Removing the imbedded application allows the host application to run perfectly.   They just can't run together.

                                                     

                                                    Is there any chance that ChartBase itself is retaining some static reference to the first application that uses it, rendering the second inoperable?

                                                    • 24. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                      luciano.bustos Community Member

                                                      I forget to mention that you have to add that code into the module.mxml file.

                                                       

                                                      MyModule.xml

                                                      override public function get moduleFactory():IFlexModuleFactory

                                                      {

                                                          return FlexGlobals.topLevelApplication.moduleFactory;

                                                      }

                                                       

                                                      And on your "shell" app  (wich load modules) try this.

                                                       

                                                      Some place on your ShellApplication.mxml

                                                      var minfo:IModuleInfo = ModuleManager.getModule(url_path);

                                                      minfo.load(target, null, null, FlexGlobals.topLevelApplication.moduleFactory);

                                                      • 25. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                        CharlieSkin Community Member

                                                        I had similar problem. A module that uses Charts cannot load the styles.

                                                         

                                                        The solution was to create a Class that has a property of the type of each Chart that is used. And create an instance of this class in the main "shell" app.

                                                         

                                                        In my case we only used PieChart and ColumnChart, so I just needed to add two properties.

                                                         

                                                        import mx.charts.ColumnChart;
                                                        import mx.charts.PieChart;

                                                        class MxComponents
                                                        {
                                                        private var varChartsOne:PieChart;
                                                        private var varChartsTwo:ColumnChart;
                                                        }

                                                         

                                                         

                                                         

                                                         

                                                         

                                                         

                                                         

                                                        • 26. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                          miki escolar Community Member

                                                          Hi guys,

                                                           

                                                          we are facing the same problem with charting components in a module application. we try to apply all your tips, but no rules!!! When using @charlieSkin solution we are able to load the module, but Parsley instantiation in module fails.

                                                           

                                                          Thanks in advance.

                                                          • 27. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                            Iamlixs Community Member

                                                            hi,I find a solution:

                                                             

                                                            as flowing:

                                                             

                                                            in the main mxml file, add a chart object  which type you used in the module file

                                                            for example:

                                                            private var _PieChart : PieChart = new  PieChart();

                                                             

                                                            then the application work correct.

                                                            hope to help.

                                                            • 28. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                              odejonge Community Member

                                                              A way to solve this is to manually update all styles from your root stylemanager to your module stylemanager.

                                                              In de module main mxml class you add when you have a LineChart in your module:

                                                               

                                                              {code}

                                                              <?xml version="1.0" encoding="utf-8"?>

                                                              <s: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%" preinitialize="preinitializeHandler(event)"

                                                                                    xmlns:swiz="http://swiz.swizframework.org">

                                                              <fx:Script>

                                                                                  <![CDATA[

                                                                                            import mx.core.FlexGlobals;

                                                                                            import mx.events.FlexEvent;

                                                               

                                                                                            protected function preinitializeHandler(event:FlexEvent):void

                                                                                            {

                                                                                                      var styleObjects:Array = FlexGlobals.topLevelApplication.styleManager.selectors;

                                                                                                      for each(var styleObj:String in styleObjects)  {

                                                                                                                var style:CSSStyleDeclaration = FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration(styleObj);

                                                                                                                styleManager.setStyleDeclaration(styleObj, style, true);

                                                                                                      }

                                                                                            }

                                                              {/code}

                                                               

                                                              This fixes the problem

                                                              • 29. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                                odejonge Community Member

                                                                override public function get moduleFactory():IFlexModuleFactory

                                                                {

                                                                    return FlexGlobals.topLevelApplication.moduleFactory;

                                                                }

                                                                 

                                                                I don't see how this is going to work when you have e.g. a LineChart that wants to get it's styles in a Module. Do you want me to extend all LineChart classe and then add this function everywhere where the stylemanager is used?

                                                                 

                                                                Olivier

                                                                • 30. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                                  mtschudi Community Member

                                                                  I have a widget with a chart embedded in another widget. Worked fine under 4.1 SDK; crashes with

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

                                                                         at mx.charts.chartClasses::ChartBase/initStyles()

                                                                  under 4.6. Adding odejonge's preinitialization to the widget with the chart fixed the problem.

                                                                   

                                                                  {code}

                                                                  <s:HGroup width="100%" height="100%"

                                                                            includeInLayout="{columnChartList.length > 0 ? true : false}"

                                                                            visible="{columnChartList.length > 0 ? true : false}">

                                                                            <mx:ColumnChart id="myChart"

                                                                          width="95%" height="150"

                                                                          dataProvider="{columnChartList}">

                                                                          <mx:horizontalAxis>

                                                                              <mx:CategoryAxis categoryField="namefield"/>

                                                                          </mx:horizontalAxis>

                                                                          <mx:series>

                                                                              <mx:ColumnSeries displayName="field" xField="namefield" yField="field"/>

                                                                          </mx:series>

                                                                      </mx:ColumnChart>

                                                                  </s:HGroup>

                                                                  {/code}

                                                                   

                                                                  Thanks, Olivier!

                                                                   

                                                                  Mike

                                                                  • 31. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                                    flexcf444 Community Member

                                                                    Need some help. I can't get any of the solutions to work?? Thanks!

                                                                    • 32. Re: Flex 4.6 unable load module, if it contains a chart component.
                                                                      Engaged Inquiry Community Member

                                                                      Luciano's solution worked for me. I mimicked his settings for RSL and debugging. I have not tested it in production, but these settings work for modular development. Note both the shell project and the modules project need these settings. The base library which actually contains the charting code is the rsl.

                                                                       

                                                                      Muchas gracias Luiano.