![](/img/trans.png)
[英]Flex Error #1009: Cannot access a property or method of a null object reference
[英]Error: Cannot access a property or method of a null object reference in flex
在没有数据的高级datagrid中运行checkBox项目渲染器时出错。 错误:无法访问空对象引用的属性或方法。
请找到以下代码:
**
public function set listData(value:BaseListData):void
{
_listData=value;
_dataGrid=value.owner as AdvancedDataGrid;
_dataField=(value as AdvancedDataGridListData).dataField;
}
**这里的值即将为空,所以我遇到了异常。 请让我知道如何解决它。
谢谢,拉维
在尝试访问value属性之前,请检查是否为null:
_dataGrid = value != null ? value.owner as AdvancedDataGrid : null;
_dataField = value != null ? (value as AdvancedDataGridListData).dataField : null;
这样,如果value为null,则_dataGrid和_dataField将仅设置为null,从而避免了运行时错误。
希望能有所帮助。
我糊涂了。
首先,该复选框已经包含一个从Button继承的listData属性: http : //livedocs.adobe.com/flex/3/langref/mx/controls/Button.html#listData 。 为什么需要实施一个新的?
其次,itemRenderer的ListData属性已经使您可以访问listData属性。 为什么需要将它们本地存储在渲染器中?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.