当前位置: 代码迷 >> Web前端 >> 给只读属性平添[Bindable]
  详细解决方案

给只读属性平添[Bindable]

热度:98   发布时间:2012-10-08 19:54:56.0
给只读属性添加[Bindable]

在flex中,如果给一个只读属性添加Bindable,会出现异常。因为只读属性的变化,不是通过setter来完成的,有可能是在代码的任何地方,通过其他方式来完成的,flex不希望消耗性能来做这种检查。而如果希望对一个只读属性进行绑定,就要告诉flex,这个属性会通过什么方式改变。比如说一个按钮被点击时更新。

button.addEventListener(MouseEvent.CLICK,function():void{
	dispatchEvent( new Event("userNameChange"));
});

[Bindable(event=“userNameChange”)]
public function get userName():String{
	return _userName;
}
  相关解决方案