我有一個組件中的可綁定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