我想在actionscript中绑定一个带有条件的布尔值。这在mxml中是可能的,但是如何在actionscript上完成?
示例:
.mxml绑定:
enabled={(A_changed || B_changed || C_changed || D_changed) && rs.selectedIndex !=-1}/>
.as binding:
BindingUtils.bindProperty(this.myBtn,'enabled',????);
谢谢, 戴夫
答案 0 :(得分:0)
您的问题没有懒惰的解决方案 - Flex编译器在MXML绑定中进行了大量转换,这些转换在vanilla AS3中不可用。您必须将BindingUtils.bindSetter附加到所有属性。类似的东西:
var closure:Function = function(...triggers):void {
enabled = (A_changed || B_changed || C_changed || D_changed) && rs.selectedIndex !=-1;
}
BindingUtils.bindSetter(closure, this, "A_changed");
BindingUtils.bindSetter(closure, this, "B_changed");
BindingUtils.bindSetter(closure, this, "C_changed");
BindingUtils.bindSetter(closure, this, "D_changed");
BindingUtils.bindSetter(closure, rs, "selectedIndex");