设置项目flex组合框

时间:2013-02-11 06:21:42

标签: actionscript-3 flex actionscript air

我有一个组合框(flex 4),我想设置一个项目。

var tempObject:Object;
tempObject.clientName="Raju";
clientList.selectedItem = tempObject;

这是对的吗? 。但是它显示了这个错误

*TypeError: Error #1009: Cannot access a property or method of a null object reference.*

我的组合框:

<s:ComboBox id="clientList" width="14%" height="85%"change="clientList_changeHandler(event)"
    dataProvider="{clientListForcombo}" labelField="clientName"
    prompt="Select the  one"/>

1 个答案:

答案 0 :(得分:2)

为什么不初始化tempObject?

试试这个:

var tempObject:Object = new Object();
tempObject.clientName="Raju";
clientList.selectedItem = tempObject;