Actionscript 3 我的错误#1010情况
编辑3:好的,我正在启动一个Windows Server 2008 R2虚拟机,安装Flex Builder 3,看看是否可以获得一个新项目来正确编译和执行。新闻!我在虚拟机中启动并运行了IDE,在编译代码之后,我仍然得到了相同的错误!这里有一个大的、强调的双发球效率 编辑2:由于这是一篇相当长的文章,我将把它放在这里。我只是逐一检查并删除了这两个问题行的每一部分,并尝试在每一行之后进行编译,每次都会出现错误。我甚至删除了两个Actionscript 3 我的错误#1010情况,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,编辑3:好的,我正在启动一个Windows Server 2008 R2虚拟机,安装Flex Builder 3,看看是否可以获得一个新项目来正确编译和执行。新闻!我在虚拟机中启动并运行了IDE,在编译代码之后,我仍然得到了相同的错误!这里有一个大的、强调的双发球效率 编辑2:由于这是一篇相当长的文章,我将把它放在这里。我只是逐一检查并删除了这两个问题行的每一部分,并尝试在每一行之后进行编译,每次都会出现错误。我甚至删除了两个DataGridColumns中的所有内容,但它仍然没有编译,即使注释
DataGridColumn
s中的所有内容,但它仍然没有编译,即使注释掉两个空
行会让程序加载!这让我快发疯了,有人能帮我解释一下吗?/Edit 2 我有一个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>
接下来是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);
}
}
}
包
{
导入mx.controls.Label;
导入mx.controls.listClasses.*;
公共类PD5扩展标签
{
私有常量正色:uint=0x000000;//黑色
私有常量负颜色:uint=0xFF0000;//红色
重写受保护的函数updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):无效
{
super.updateDisplayList(unscaledWidth、unscaledHeight);
setStyle(“color”(data.PreviousDateDelta>=5 | | | | data.PreviousDateDelta=5 | | | | data.previousMontHendDelta代码中没有任何错误。
显然,这是未经测试的代码。
我感觉您的数据提供程序不完整或缺少数据。
可能是因为其中一行。
// no validation is being done so this can be a failure point
var Field:Object = item[column.dataField];
return format1.format(Field);
return format2.format(Field);
下面是一些您可以尝试测试数据提供程序的代码
import flash.debugger.enterDebugger;
private function formatUtil1(item:Object, column:DataGridColumn):String
{
try{
if (item[column.dataField] ){
var Field:Object = item[column.dataField];
var retVal:String = format1.format(Field)
if( retVal == null || retVal == undefined ){
//return '';
enterDebugger()
}
}else{
//return '';
enterDebugger()
}
}catch(e:error){
//return '';
enterDebugger()
}
return retVal;
}
private function formatUtil2(item:Object, column:DataGridColumn):String
{
try{
if (item[column.dataField] ){
var Field:Object = item[column.dataField];
var retVal:String = format2.format(Field);
if( retVal == null || retVal == undefined ){
//return '';
enterDebugger()
}
}else{
//return '';
enterDebugger()
}
}catch(e:error){
//return '';
enterDebugger()
}
return retVal;
}
同样的事情也可以应用于渲染器
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, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
// are you 100% sure data.PrevMonthEndDelta exists on the data object????
if (data != null && data.PreviousDateDelta ){
setStyle("color", (data.PrevMonthEndDelta >= 5 || data.PrevMonthEndDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR);
}
}
}
}
包
{
导入mx.controls.Label;
导入mx.controls.listClasses.*;
公共类PME5扩展了标签
{
私有常量正色:uint=0x000000;//黑色
私有常量负颜色:uint=0xFF0000;//红色
重写受保护的函数updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):无效
{
super.updateDisplayList(unscaledWidth、unscaledHeight);
//是否100%确定数据对象上存在data.PrevMonthEndDelta????
if(data!=null&&data.PreviousDateDelta){
setStyle(“color”,(data.PrevMonthEndDelta>=5 | | data.PrevMonthEndDelta此处编译良好。除了添加默认数据外,未更改任何内容
<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">
<fx:Script>
<![CDATA[
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);
}
private function formatUtil3(item:Object, column:DataGridColumn):String
{
return formatUtil2(item, column);
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="format2" precision="2"/>
<mx:CurrencyFormatter id="format1" precision="5" useNegativeSign="false"/>
</fx:Declarations>
<mx:DataGrid id="grid1" width="100%" height="100%" editable="false">
<mx:ArrayCollection>
<mx:source>
<fx:Object
Symbol="€"
FullName="Name"
TransactionCode="121345"
Quantity="10"
ExecutionDate="10.10.2011"
ExecutionPrice="1.5"
PreviousDate="09.10.2011"
PreviousDatePrice="1.4"
PreviousDateDelta="10"
PreviousDateSource="0.1"
PrevMonthEndDate="0.1"
PrevMonthEndPrice="0.1"
PrevMonthEndDelta="-10"
PrevMonthEndSource="0.1"
/>
<fx:Object
Symbol="€"
FullName="Name2"
TransactionCode="121345"
Quantity="10"
ExecutionDate="10.10.2011"
ExecutionPrice="1.5"
PreviousDate="09.10.2011"
PreviousDatePrice="1.4"
PreviousDateDelta="4"
PreviousDateSource="0.1"
PrevMonthEndDate="0.1"
PrevMonthEndPrice="0.1"
PrevMonthEndDelta="4"
PrevMonthEndSource="0.1"
/>
</mx:source>
</mx:ArrayCollection>
<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="tmp.PD5"/>
<mx:DataGridColumn headerText="Previous Business Day Price" dataField="PreviousDatePrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="tmp.PD5"/>
<mx:DataGridColumn headerText="% Difference" dataField="PreviousDateDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="tmp.PD5"/>
<mx:DataGridColumn headerText="Source" dataField="PreviousDateSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="tmp.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="tmp.PME5"/>
<mx:DataGridColumn headerText="Previous Month End Price" dataField="PrevMonthEndPrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="tmp.PME5"/>
<mx:DataGridColumn headerText="% Difference" dataField="PrevMonthEndDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="tmp.PME5"/>
<mx:DataGridColumn headerText="Source" dataField="PrevMonthEndSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="tmp.PME5"/>
</mx:columns>
</mx:DataGrid>
</s:Application>
在调试模式下运行应用程序。出现错误时,Flex builder(Flash builder 4.5是最新版本)将中断并将您带到导致问题的代码行。发生这种情况是因为您尝试访问其属性的某个对象实际上为空
您可以在调试窗口(窗口菜单>调试)中上下浏览调用树,这样您就可以找出哪个对象是空的
发生这种情况的主要原因是数据提供程序不完整,即缺少一些数据。例如,一行可能没有前一天的业务价格。如果是这种情况,则需要在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.PrevMonthEndDelta>=5 | | | data.PrevMonthEndDelta=5 | | data.PreviousDateDelta由于到目前为止还没有解决我的问题,所以我决定完全避开它,将有问题的程序移植到C#。到目前为止,一切都运行良好
懒惰的回答?是的。
懒惰的解决方案?不幸的是没有。拿出labelFunction,看看你是否编译。我感觉这些函数中有未定义的引用。@阿斯曼-刚刚做了,不是labelFunction
s。此外,它们在故障行下面的两行中工作。是的,我在后面的几行中没有看到它们。这很奇怪。唯一的是我看到的是使用labelfunc formatUtil和formatUtil2工作的行上的renender将renender从PD5更改为PME5,然后看看是什么happens@The_asMan-删除itemRenderer=“PD5”
每一行都没有帮助。你能发布PME5、PD5、formatUtil1和FormatUtil2吗?我确实需要对这些函数进行某种验证,但用户必须手动启动应用程序的任何操作。这个错误甚至在应用程序实际打开之前就发生了,并且在有问题的DataGridColumn
s显示,直到用户点击“go”button.ah那么它在第一次运行时的渲染器数据==null,因此data.PrevMonthEndDelta将不存在。编辑我的帖子我不认为这是问题所在,因为它没有解释为什么那些非常相同的渲染器仍然在其他行上工作而没有问题。我不知道,但我知道渲染器的第一次运行时总是null以前遇到过这种情况,只是给它一个空测试,就像我添加了空检查一样,仍然存在问题。我更改了formatUtil
函数,但没有效果,正如前面所述,我已经多次删除了两个问题行中的itemRenderer
调用,但没有效果。您是在调试模式下运行的吗电子应用程序坏了?我坏了,错误与我在问题中发布的对话框相匹配
<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">
<fx:Script>
<![CDATA[
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);
}
private function formatUtil3(item:Object, column:DataGridColumn):String
{
return formatUtil2(item, column);
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="format2" precision="2"/>
<mx:CurrencyFormatter id="format1" precision="5" useNegativeSign="false"/>
</fx:Declarations>
<mx:DataGrid id="grid1" width="100%" height="100%" editable="false">
<mx:ArrayCollection>
<mx:source>
<fx:Object
Symbol="€"
FullName="Name"
TransactionCode="121345"
Quantity="10"
ExecutionDate="10.10.2011"
ExecutionPrice="1.5"
PreviousDate="09.10.2011"
PreviousDatePrice="1.4"
PreviousDateDelta="10"
PreviousDateSource="0.1"
PrevMonthEndDate="0.1"
PrevMonthEndPrice="0.1"
PrevMonthEndDelta="-10"
PrevMonthEndSource="0.1"
/>
<fx:Object
Symbol="€"
FullName="Name2"
TransactionCode="121345"
Quantity="10"
ExecutionDate="10.10.2011"
ExecutionPrice="1.5"
PreviousDate="09.10.2011"
PreviousDatePrice="1.4"
PreviousDateDelta="4"
PreviousDateSource="0.1"
PrevMonthEndDate="0.1"
PrevMonthEndPrice="0.1"
PrevMonthEndDelta="4"
PrevMonthEndSource="0.1"
/>
</mx:source>
</mx:ArrayCollection>
<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="tmp.PD5"/>
<mx:DataGridColumn headerText="Previous Business Day Price" dataField="PreviousDatePrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="tmp.PD5"/>
<mx:DataGridColumn headerText="% Difference" dataField="PreviousDateDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="tmp.PD5"/>
<mx:DataGridColumn headerText="Source" dataField="PreviousDateSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="tmp.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="tmp.PME5"/>
<mx:DataGridColumn headerText="Previous Month End Price" dataField="PrevMonthEndPrice" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil1" itemRenderer="tmp.PME5"/>
<mx:DataGridColumn headerText="% Difference" dataField="PrevMonthEndDelta" headerWordWrap="true" width="65" textAlign="right" labelFunction="formatUtil2" itemRenderer="tmp.PME5"/>
<mx:DataGridColumn headerText="Source" dataField="PrevMonthEndSource" headerWordWrap="true" width="100" textAlign="left" itemRenderer="tmp.PME5"/>
</mx:columns>
</mx:DataGrid>
</s:Application>
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);