问题描述:
FLEX应用中有三个states,通过下拉列表切换state,三个state中显示的控件分别为:datagrid,chart,datagrid/chart;
当由只显示表格的视图切换到只显示图表的视图时,出现以下的错误:
TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at mx.charts.chartClasses::ChartLabel/updateDisplayList()[C:/work/flex/dmv_automation/projects/datavisualisation/src/mx/charts/chartClasses/ChartLabel.as:262]
at mx.core::UIComponent/validateDisplayList()[C:/autobuild/3.2.0/frameworks/projects/framework/src/mx/core/UIComponent.as:6351]
at mx.managers::LayoutManager/validateDisplayList()[C:/autobuild/3.2.0/frameworks/projects/framework/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()
at mx.core::UIComponent/callLaterDispatcher2()[C:/autobuild/3.2.0/frameworks/projects/framework/src/mx/core/UIComponent.as:8628]
at mx.core::UIComponent/callLaterDispatcher()[C:/autobuild/3.2.0/frameworks/projects/framework/src/mx/core/UIComponent.as:8568]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
上网搜了一下,发现问题出在<mx:LinearAxis title="平均耗时"/>上
FLEX BUG描述请参考:https://bugs.adobe.com/jira/browse/FLEXDMV-2088根据BUG ISSUE提供的解决方案,我采用了以下的方法:
创建 CustomerChartTitleRenderer
package mx.controls.extend.chart
{
import mx.charts.chartClasses.ChartLabel;
import mx.core.IDataRenderer; public class CustomerChartTitleRenderer extends ChartLabel implements IDataRenderer
{
public function CustomerChartTitleRenderer()
{
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
if (parent == null){
return;
}
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
}
}
将mxml中
<mx:verticalAxis>
<mx:LinearAxis title="平均耗时"/>
</mx:verticalAxis>
修改为
<mx:verticalAxisRenderers>
<mx:AxisRenderer titleRenderer="mx.controls.extend.chart.CustomerChartTitleRenderer">
<mx:axis>
<mx:LinearAxis title="平均耗时"/>
</mx:axis>
</mx:AxisRenderer> </mx:verticalAxisRenderers>
问题解决。
标签:UIComponent,FLEX,use,autobuild,core,LinearAxis,src,mx,projects From: https://blog.51cto.com/u_16129500/6354920