1

我想在 actionscript 中绑定一个带有条件的布尔值。这在 mxml 中是可能的,但是如何在 actionscript 上做到这一点?

例子:

.mxml 绑定:

enabled={(A_changed || B_changed  || C_changed || D_changed) && rs.selectedIndex !=-1}/>

.as 绑定:

BindingUtils.bindProperty(this.myBtn,'enabled',????);

谢谢,戴夫

4

1 回答 1

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");
于 2012-09-17T17:01:06.620 回答