TypeError: Error #1034: 强制转换类型失败:无法将 "" 转换为 Array。
Posted jzdwajue
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: Error #1034: 强制转换类型失败:无法将 "" 转换为 Array。相关的知识,希望对你有一定的参考价值。
1、错误描写叙述
TypeError: Error #1034: 强制转换类型失败:无法将 "" 转换为 Array。at mx.charts.series::LineSeries/updateFilter()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\series\LineSeries.as:1225] at mx.charts.chartClasses::Series/validateTransform()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\Series.as:1916] at mx.charts.chartClasses::Series/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\Series.as:948] at mx.charts.series::LineSeries/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\series\LineSeries.as:983] at mx.core::UIComponent/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8531] at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:663] at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718] at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
2、错误原因
<?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" width="100%" height="100%" fontSize="12" fontFamily="微软雅黑"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.charts.ChartItem; import mx.charts.chartClasses.Series; import mx.charts.series.items.LineSeriesItem; import mx.collections.ArrayCollection; import mx.events.FlexEvent; import mx.graphics.Stroke; [Bindable] //折线图数据绑定 private var lineArray:ArrayCollection = new ArrayCollection([ {seasons:"春季",rate:"0.48677"}, {seasons:"夏季",rate:"0.122343232"}, {seasons:"秋季",rate:"0.5657645"}, {seasons:"冬季",rate:"0.67484889"} ]); /** * 设置折线图中比率的位数 */ public function dataFunction(series:Series, item:Object, fieldName:String):Object { var temp:Number = item.rate; var number:String = formatter.format(temp); return number; } public function myFillFunction(item:ChartItem, index:Number):String { var curItem:LineSeriesItem = LineSeriesItem(item); var num:String = formatter.format(curItem.yNumber); return num; } public function myFilterFunction(item:Object):String { var temp:Number = item.rate; var number:String = formatter.format(temp); return number; } ]]> </fx:Script> <fx:Declarations> <mx:NumberFormatter id="formatter" precision="2" rounding="up"/> </fx:Declarations> <mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="15" paddingTop="10" horizontalAlign="center"> <mx:LineChart id="line" width="100%" height="90%" dataProvider="{lineArray}" showDataTips="true"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="seasons" displayName="四季"/> </mx:horizontalAxis> <mx:horizontalAxisRenderers> <mx:AxisRenderer placement="bottom" tickLength="1" tickStroke="{new Stroke(0xFF0000,1)}" axisStroke="{new Stroke(0xFF0000,1)}"> <mx:axis> <mx:LinearAxis id="bottomAxis"/> </mx:axis> </mx:AxisRenderer> </mx:horizontalAxisRenderers> <mx:verticalAxisRenderers> <mx:AxisRenderer placement="left" tickLength="1" tickStroke="{new Stroke(0xFF0000,1)}" axisStroke="{new Stroke(0xFF0000,1)}"> <mx:axis> <mx:LinearAxis id="leftAxis"/> </mx:axis> </mx:AxisRenderer> </mx:verticalAxisRenderers> <mx:series> <mx:LineSeries verticalAxis="{leftAxis}" displayName="比率" xField="seasons" yField="rate" filterFunction="myFilterFunction"/> </mx:series> <mx:filters> <fx:Array/> </mx:filters> </mx:LineChart> <mx:Legend dataProvider="{line}"/> </mx:VBox> </s:Application>
3、解决的方法
以上是关于TypeError: Error #1034: 强制转换类型失败:无法将 "" 转换为 Array。的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3.0和'TypeError:错误#1034:类型强制失败'
Light OJ 1034 - Hit the Light Switches(强联通分量)
PAT 甲级 1034 Head of a Gang (30 分)(bfs,map,强连通)
TypeError:错误#1034:类型强制失败:无法将Object @ 1456c7b9转换为mx.messaging.messages.IMessage