我在Spark下拉列表中更新selectedItem属性时遇到问题。
列表实现如下所示:
<s:DropDownList prompt="Please Choose" labelField="name" selectedItem="@{overheating.kindOfConstruction}" width="180" styleName="dropDownListStyle">
<s:dataProvider>
<s:ArrayCollection>
<Model:ConstructionKind>
<Model:name>Massive Construction</Model:name>
<Model:value>204</Model:value>
</Model:ConstructionKind>
<Model:ConstructionKind>
<Model:name>Lightweight Construction</Model:name>
<Model:value>60</Model:value>
</Model:ConstructionKind>
</s:ArrayCollection>
</s:dataProvider>
</s:DropDownList>
列表绑定到带有两个“ConstructionKind”对象的ArrayCollection。 “ConstructionKind”对象实现如下:
public class ConstructionKind
{
private var _name:String = '';
private var _value:Number = 0;
public function ConstructionKind()
{
}
[Bindable]
public function get value():Number
{
return _value;
}
public function set value(value:Number):void
{
_value = value;
}
[Bindable]
public function get name():String
{
return _name;
}
public function set name(value:String):void
{
_name = value;
}
}
列表的selectedItem属性绑定到一个对象,该对象具有类型为“ConstructionKind”的可绑定属性constructionKind。当我执行以下代码时,DropDownList不会更新:
overheating.kindOfConstruction = new ConstructionKind();
overheating.kindOfConstruction.name = "Massive Construction";
overheating.kindOfConstruction.value = 204;
执行此操作时,列表的selectedItem为null。我的问题是: 这个数据绑定是如何工作的?它是否需要dataprovider中对象的相同实例。或者它正在检查对象属性的值?