0
我試圖在數值爲< 0時使數據紅色,否則爲綠色。我用來顯示列和我的itemRenderer動作腳本文件給我錯誤「無法訪問屬性的一個null
對象,在我作爲文件,當我調試時,我可以看到」數據「變量的值爲null
,並儘快它調用超級構造它給這個錯誤flex 4.5中的自定義着色錯誤Mobile
我的動作腳本文件
public class ConditionalColoredLabelAS extends LabelItemRenderer
{
public function ConditionalColoredLabelAS() {
if (data !=null)
super();
}
// Use the value of the myColor property to draw
// the background color of the item in the list.
override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void {
// Define a var to hold the color.
var myColor:uint;
if (data !=null)
{
// Determine the RGB color value from the label property.
if (data == "red")
myColor = 0xFF0000;
if (data == "green")
myColor = 0x00FF00;
if (data == "blue")
myColor = 0x0000FF;
}
//graphics.beginFill(myColor, 1);
//graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
}
}
我從MXML文件調用:
<s:GridColumn id="name1" dataField="name" headerText="Name" />
<s:GridColumn dataField="excess_return" headerText="Excess Return" itemRenderer="util.ConditionalColoredLabelAS"/>
錯誤是
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spark.components::Group/addElement()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\Group.as:1342]
at spark.components.gridClasses::GridLayout/createTypicalItemRenderer()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\gridClasses\GridLayout.as:748]
at spark.components.gridClasses::GridLayout/updateTypicalCellSizes()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\gridClasses\GridLayout.as:883]
at spark.components.gridClasses::GridLayout/measure()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\gridClasses\GridLayout.as:444]
at spark.components.supportClasses::GroupBase/measure()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\supportClasses\GroupBase.as:1148]
at mx.core::UIComponent/measureSizes()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8496]
at mx.core::UIComponent/validateSize()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8420]
at spark.components::Group/validateSize()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\Group.as:1012]
at mx.managers::LayoutManager/validateClient()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:987]
at mx.core::UIComponent/validateNow()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8067]
at spark.components::ViewNavigator/commitNavigatorAction()[E:\dev\4.5.1\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1878]
at spark.components::ViewNavigator/commitProperties()[E:\dev\4.5.1\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1236]
at mx.core::UIComponent/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:783]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]
這並沒有讓我把東方電氣araions,所以在這裏它們的 的 \t
FX:組件> \t \t 的FX:組件> 的FX:組件> fx:聲明> – Vaibhav