Is there a known bug when displaying a chart component that is defined in a module. When attempting to display a chart component defined in a module it crashes indicating Error #1009: Cannot access a property or method of a null object reference.
It crashes at the following location in ChartBase.as. Somehow when loading the chart the styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase"); returns null so when using the setStyle methods the exception occurs.
private function initStyles():Boolean
{
HaloDefaults.init(styleManager);
var chartBaseStyle:CSSStyleDeclaration = styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase");
chartBaseStyle.setStyle("chartSeriesStyles", HaloDefaults.chartBaseChartSeriesStyles);
chartBaseStyle.setStyle("fill", new SolidColor(0xFFFFFF, 0));
chartBaseStyle.setStyle("calloutStroke", new SolidColorStroke(0x888888,2));
return true;
}
Added note: There is a chart component in the application that works fine. The only way I can get the chart in the module to display is to add the following workaround preinitializer but it severly impacts the loading of the module. Is there a way around this.
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);
}
}
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::PolarChart/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\chartClasses\PolarCha rt.as:223] at mx.charts::PieChart/set moduleFactory()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\PieChart.as:203] 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/addElementAt()[E:\dev\4.y\frameworks\projects\spark\src\spark\com ponents\Group.as:1387] at spark.components::SkinnableContainer/addElementAt()[E:\dev\4.y\frameworks\projects\spark\ src\spark\components\SkinnableContainer.as:775] 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/setCurrentState()[E:\dev\4.y\frameworks\projects\framework\src\mx\co re\UIComponent.as:10323] at mx.core::UIComponent/set currentState()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:6425] at BloodPressure/bloodpressureDg_selectionChangeHandler()[C:\Users\Mark\Adobe Flash Builder 4.7\BiometricsFlexProject\src\BloodPressure.mxml:311] at BloodPressure/__bloodpressureDg_selectionChange()[C:\Users\Mark\Adobe Flash Builder 4.7\BiometricsFlexProject\src\BloodPressure.mxml:41] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core \UIComponent.as:13152] at spark.components::DataGrid/commitInteractiveSelection()[E:\dev\4.y\frameworks\projects\sp ark\src\spark\components\DataGrid.as:3634] at spark.components::DataGrid/setSelectionAnchorCaret()[E:\dev\4.y\frameworks\projects\spark \src\spark\components\DataGrid.as:4210] at spark.components::DataGrid/grid_mouseDownHandler()[E:\dev\4.y\frameworks\projects\spark\s rc\spark\components\DataGrid.as:4679] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core \UIComponent.as:13152] at spark.components::Grid/dispatchGridEvent()[E:\dev\4.y\frameworks\projects\spark\src\spark \components\Grid.as:4038] at spark.components::Grid/grid_mouseDownDragUpHandler()[E:\dev\4.y\frameworks\projects\spark \src\spark\components\Grid.as:3883] at Function/<anonymous>()[E:\dev\4.y\frameworks\projects\spark\src\spark\utils\MouseEventUti l.as:84] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.managers::SystemManager/mouseEventHandler()[E:\dev\4.y\frameworks\projects\framework\s rc\mx\managers\SystemManager.as:2918]