My mistake is No. 1010

Edit 3: Well, I started the Windows Server 2008 R2 virtual machine by installing Flex Builder 3 and seeing if I could create a new project to compile and execute correctly. News! I got an IDE and worked in VM, and I STILL got the exact same error after compiling the code without any problems! Here is a big, decisive double you tee eff .

Edit 2: Since this has become a rather long post, I will talk about it here. I just went through and deleted each part of the two problematic lines individually and tried to compile after each of them, and I got an error every time. I even deleted all of the two DataGridColumn , and it still has not compiled, although commenting on two empty lines <mx:DataGridColumn /> will allow the program to load! It drives me crazy, can anyone shed some light on this for me?
/ Edit 2

I have an AIR application that will apparently compile just fine when I press F5, but before the application gets the ability to download, I get the following error:

My error message.

Commenting on blocks of code, I narrowed down the problem to two specific lines.

 <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> 

Two lines are marked <!----> . If I comment on these two lines, the application will compile, run and display correctly, but if I leave them active, I will get the error above.

What's going on here?

Edit: Additional code as requested -

 <mx:CurrencyFormatter id="format1" precision="5" useNegativeSign="false"/> <mx:NumberFormatter id="format2" precision="2"/> 

And functions -

 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); } 

Then the .as file for PD5 is

 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); } } } 

And now 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, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); setStyle("color", (data.PrevMonthEndDelta >= 5 || data.PrevMonthEndDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); } } } 
+6
source share
4 answers

Since nothing has yet resolved my problem, I decided to completely bypass it and transfer the program in question to C #. Everything that works well so far.

Lazy answer? Yes.
Lazy decision? Unfortunately not.

0
source

Run the application in debug mode. If an error occurs, Flex Builder (Flash Builder 4.5 is the latest version) will break and lead you to the line of code that causes the problem. This is because some object whose property you are trying to get is actually null.

You can look up and down the call tree in the debug window (Window> Debug menu), and so you can see which object is null.

This is mainly because the date sensor is not complete, that is, some data is missing. for example, one line may not have the business price of the previous day. If so, then you need to handle the null element in your formats. Functions

 var field:Object=item[column.dataField]; if(field!=null) { return format1.format(field); } else { return ""; } 

EDIT:
Also check these two lines:

 setStyle("color", (data.PrevMonthEndDelta >= 5 || data.PrevMonthEndDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); 

and

 setStyle("color", (data.PreviousDateDelta >= 5 || data.PreviousDateDelta <= -5) ? NEGATIVE_COLOR : POSITIVE_COLOR); 

It is possible that the error comes from data.PreviousDateDelta or data.PrevMonthEndDelta

+3
source

Nothing stands out in the code as bad.
Obviously, this is untested code.
I have the feeling that your data provider is not complete or missing data. Probably due to 1 of these lines.

 // 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); 

Here is some code you can try checking your dataprovider

 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; } 

The same can be applied to renderers.

 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); } } } } 
0
source

This compiles fine. Has not changed anything except the default data added.

 <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> 
0
source

Source: https://habr.com/ru/post/895191/


All Articles