actionscript-3 – 我的错误#1010情况
编辑3:好的,我正在点亮
Windows Server 2008 R2虚拟机,安装Flex Builder 3,看看我是否可以获得一个新项目来正确编译和执行.新闻!我启动了IDE并在VM中运行,并且在编译代码之后我仍然得到了同样的错误!这里有一个很大的,有力的双重你.
编辑2:由于这已经是一个很长的帖子,我会把它放在这里.我刚刚完成并单独删除了两个问题行的每一部分,并尝试在每一行之后进行编译,每次都得到错误.我甚至删除了两个DataGridColumns中的所有内容,但它仍然没有编译,即使注释掉两个空的< mx:DataGridColumn />线条会让程序加载!这让我疯了,任何人都可以为我解释这个问题吗? 我有一个AIR应用程序,当我点击F5时显然可以正常编译,但在应用程序有机会加载之前我得到以下错误: 通过注释掉代码块,我将问题缩小到两个特定的行. <mx:DataGrid id="grid1" width="100%" height="100%" editable="false"> <mx:columns> <mx:DataGridColumn headerText="Symbol" dataField="Symbol" headerWordWrap="true" width="100" textAlign="left"/> <mx:DataGridColumn headerText="Description" dataField="FullName" headerWordWrap="true" width="150" textAlign="left"/> <mx:DataGridColumn headerText="Trans" dataField="TransactionCode" headerWordWrap="true" width="75" textAlign="center"/> <mx:DataGridColumn headerText="Quantity" dataField="Quantity" headerWordWrap="true" width="50" textAlign="right" labelFunction="formatUtil3"/> <mx:DataGridColumn headerText="Execution Date" dataField="ExecutionDate" headerWordWrap="true" width="80" textAlign="center"/> <mx:DataGridColumn headerText="Execution Price" dataField="ExecutionPrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1"/> <mx:DataGridColumn width="15" backgroundColor="0x888888" dataField="blank1" headerText=""/> <mx:DataGridColumn headerText="Previous Business Day" dataField="PreviousDate" headerWordWrap="true" width="80" textAlign="center" itemRenderer="PD5"/> <!----> <mx:DataGridColumn headerText="Previous Business Day Price" dataField="PreviousDatePrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="PD5"/> <!----> <mx:DataGridColumn headerText="% Difference" dataField="PreviousDateDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="PD5"/> <mx:DataGridColumn headerText="Source" dataField="PreviousDateSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="PD5"/> <mx:DataGridColumn width="15" backgroundColor="0x888888" dataField="blank2" headerText=""/> <mx:DataGridColumn headerText="Previous Month End" dataField="PrevMonthEndDate" headerWordWrap="true" width="80" textAlign="center" itemRenderer="PME5"/> <mx:DataGridColumn headerText="Previous Month End Price" dataField="PrevMonthEndPrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="PME5"/> <mx:DataGridColumn headerText="% Difference" dataField="PrevMonthEndDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="PME5"/> <mx:DataGridColumn headerText="Source" dataField="PrevMonthEndSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="PME5"/> </mx:columns> </mx:DataGrid> 这两行标有<!---->.如果我评论这两行,那么应用程序将正确编译,运行和显示,但如果我让其中任何一个处于活动状态,我会得到上面的错误. 这里发生了什么? 编辑:要求的附加代码 – <mx:CurrencyFormatter id="format1" precision="5" useNegativeSign="false"/> <mx:NumberFormatter id="format2" precision="2"/> 和功能 – private function formatUtil1(item:Object,column:DataGridColumn):String { var Field:Object = item[column.dataField]; return format1.format(Field); } private function formatUtil2(item:Object,column:DataGridColumn):String { var Field:Object = item[column.dataField]; return format2.format(Field); } 接下来是PD5的.as文件 – package { import mx.controls.Label; import mx.controls.listClasses.*; public class PD5 extends Label { private const POSITIVE_COLOR:uint = 0x000000; // Black private const NEGATIVE_COLOR:uint = 0xFF0000; // Red override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); setStyle("color",(data.PreviousDateDelta >= 5 || data.PreviousDateDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); } } } 现在PME5.as – package { import mx.controls.Label; import mx.controls.listClasses.*; public class PME5 extends Label { private const POSITIVE_COLOR:uint = 0x000000; // Black private const NEGATIVE_COLOR:uint = 0xFF0000; // Red override protected function updateDisplayList(unscaledWidth:Number,(data.PrevMonthEndDelta >= 5 || data.PrevMonthEndDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); } } } 解决方法
以调试模式运行应用程序.出现错误时,Flex构建器(Flash Builder 4.5是最新版本)将断开并带您进入导致问题的代码行.这是因为您尝试访问其属性的某个对象实际上为null.
您可以在调试窗口(窗口菜单> debug)中上下调用调用树,这样您就可以找出哪个对象为null. 大多数情况下会发生这种情况,因为数据提供者并不完整,即缺少一些数据.例如,一行可能没有前一天的商业价格.如果是这种情况,那么您需要处理formatUtil函数中的null项 var field:Object=item[column.dataField]; if(field!=null) { return format1.format(field); } else { return ""; } 编辑: setStyle("color",(data.PrevMonthEndDelta >= 5 || data.PrevMonthEndDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); 和 setStyle("color",(data.PreviousDateDelta >= 5 || data.PreviousDateDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); 错误可能来自data.PreviousDateDelta或data.PrevMonthEndDelta (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |