我有一个组件中的可绑定getter,通知我何时[hidden]计时器正在运行。我也有一个上下文菜单,如果这个定时器正在运行,应该禁用其中一个菜单项。是否有可能创建一个ChangeWatcher,它监视可绑定属性/获取器的负数条件并更改菜单项的enabled
属性?Flex ChangeWatcher绑定到负面条件
下面是我试图绑定在一起的基本方法:
A类:
[Bindable]
public function get isPlaying():Boolean {
return (_timer != null) ? _timer.running : false;
}
B类:
private var _playingWatcher:ChangeWatcher;
public function createContextMenu():void {
//...blah blah, creating context menu
var newItem:ContextMenuItem = new ContextMenuItem();
_playingWatcher = BindingUtils.bindProperty(newItem, "enabled", _classA, "isPlaying");
}
在上面的代码中,我有逆case:当isPlaying()为true时,菜单项被启用;我希望它只在条件为false时才启用。
我可以创建一个第二吸附材料(有依赖于当前的吸气其他绑定)返回逆条件,但听起来丑对我说:
[Bindable]
public function get isNotPlaying():Boolean {
return !isPlaying;
}
这是可能的,或者是有其他方法我完全失踪?
的“绑定属性是盲” - 是啊,我怕的就是这个:) – bedwyr 2011-01-08 03:05:08