【发布时间】:2010-01-23 03:08:55
【问题描述】:
好吧,我有一个组合框,我将他的 selectedItem 属性绑定到一个值对象对象,就像这样
<fx:Binding source="styles_cb.selectedItem.toString()" destination="_uniform.style"/>
<fx:Declarations>
<fx:XML id="config_xml" xmlns="" source="config.xml" />
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:ComboBox x="66.15" y="63.85" editable="false" id="styles_cb" dataProvider="{config_xml.styles.style}" />
值对象是一个带有一些setter和getter的自定义类,我想根据组合的selectedItem的值设置一个属性,所以在值对象里面我有这样的东西
[Bindable]
public function set style(value:String):void
{
_style = value;
trace(value);
}
我的问题是,每次我更改组合框选择时,实际上会更改值对象的样式属性,它会执行 3 次,如果我跟踪 setter 的值,它实际上会跟踪 3 次,为什么?我怎样才能避免这种情况?我做错了什么?或者有更好的方法,请帮忙,谢谢您的帮助
【问题讨论】:
标签: apache-flex actionscript-3 data-binding