Skip navigation
niranjan swain
Currently Being Moderated

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

Dec 27, 2011 4:44 AM

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\proje cts\framework\src\mx\core\UIComponent.as:8219]

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

at mx.managers::PopUpManagerImpl/addPopUp()

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

 

Thanks in Advance

Niranjan Swain

 
Replies
  • Currently Being Moderated
    Dec 27, 2011 9:37 AM   in reply to niranjan swain

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:17 AM   in reply to saisri2k2

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:38 AM   in reply to kmwill23

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:40 AM   in reply to Flex harUI

    It is the exact stack trace of the original poster.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:53 AM   in reply to kmwill23

    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;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:58 AM   in reply to kmwill23

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 12:05 PM   in reply to kmwill23

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 12:12 PM   in reply to kmwill23

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 12:19 PM   in reply to Flex harUI

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 5:45 PM   in reply to kmwill23

    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\c hartClasses\ChartBase.as:1894]

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

              at mx.charts::LineChart/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\L ineChart.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\projec ts\spark\src\spark\components\Group.as:633]

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

              at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\core\UIComponent.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\fram ework\src\mx\core\UIComponent.as:7199]

              at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\fr ameworks\projects\spark\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\components\Group.as:1387]

              at mx.states::AddItems/addItemsToContentHolder()[E:\dev\4.y\frameworks\p rojects\framework\src\mx\states\AddItems.as:782]

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

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

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

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

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

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

              at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\proje cts\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\framewo rks\projects\framework\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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2012 11:29 PM   in reply to kmwill23

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 6:13 AM   in reply to Flex harUI

    The moduel factory is...

     

    "moduleFactory"_Graphs_mx_managers_SystemManager (@72620a1)
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 2:21 PM   in reply to kmwill23

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 2:49 PM   in reply to Flex harUI

    Small test case?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 3:18 PM   in reply to kmwill23

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2012 8:24 AM   in reply to Flex harUI

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2012 8:32 AM   in reply to kmwill23

    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}

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2012 12:20 PM   in reply to niranjan swain

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2012 12:39 PM   in reply to luciano.bustos

    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.loadi ngContainer.SkinnableContainerSkin23.contentGroup.VGroup25.chartDispla y.PanelSkin27._PanelSkin_Group1.contents.contentGroup.performanceChart s.FlexLoader36.instance49.Graphs42.ApplicationSkin43._ApplicationSkin_ Group1.contentGroup.VGroup46.HGroup47.ddlGraphChoice cannot be found.

              at spark.components.supportClasses::SkinnableComponent/attachSkin()[E:\d ev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\S kinnableComponent.as:698]

              at spark.components.supportClasses::SkinnableComponent/validateSkinChang e()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportC lasses\SkinnableComponent.as:443]

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

              at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\core\UIComponent.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\fram ework\src\mx\core\UIComponent.as:7199]

              at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\fr ameworks\projects\spark\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\projec ts\spark\src\spark\components\Group.as:633]

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

              at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\core\UIComponent.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\fram ework\src\mx\core\UIComponent.as:7199]

              at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\fr ameworks\projects\spark\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\projec ts\spark\src\spark\components\Group.as:633]

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

              at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\fram ework\src\mx\core\UIComponent.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\fram ework\src\mx\core\UIComponent.as:7199]

              at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\fr ameworks\projects\spark\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\projec ts\spark\src\spark\components\Group.as:633]

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

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

              at spark.components::SkinnableContainer/createDeferredContent()[E:\dev\4 .y\frameworks\projects\spark\src\spark\components\SkinnableContainer.a s:1050]

              at spark.components::SkinnableContainer/createContentIfNeeded()[E:\dev\4 .y\frameworks\projects\spark\src\spark\components\SkinnableContainer.a s:1078]

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

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

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

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

              at Graphs/initialize()

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

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

              at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\4.y\fram eworks\projects\framework\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\SystemMana ger.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\SystemMana ger.as:2723]

              at flash.events::EventDispatcher/dispatchEventFunction()

              at flash.events::EventDispatcher/dispatchEvent()

              at mx.preloaders::Preloader/timerHandler()[E:\dev\4.y\frameworks\project s\framework\src\mx\preloaders\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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2012 12:58 PM   in reply to niranjan swain

    Actually is working for me.

     

    My module proyect configuration

     

    flexmoduleconfig.PNG

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 7:48 AM   in reply to luciano.bustos

    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 =)

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 7:53 AM   in reply to niranjan swain

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 8:07 AM   in reply to luciano.bustos

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 8:16 AM   in reply to niranjan swain

    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);

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2012 3:49 AM   in reply to luciano.bustos

    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;
    }

     

     

     

     

     

     

     

    
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2012 8:46 AM   in reply to CharlieSkin

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2012 8:43 AM   in reply to niranjan swain

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:37 PM   in reply to niranjan swain

    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(styl eObj);

                                                      styleManager.setStyleDeclaration(styleObj, style, true);

                                            }

                                  }

    {/code}

     

    This fixes the problem

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2012 2:41 PM   in reply to luciano.bustos

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 14, 2012 3:54 PM   in reply to odejonge

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2012 9:36 AM   in reply to mtschudi

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 1:58 PM   in reply to luciano.bustos

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2013 1:22 PM   in reply to luciano.bustos

    This worked for me. Thanks

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points