我可以将Flex组件属性绑定到函数吗?

我想根据具有一个或多个参数的函数的返回值在按钮上设置enabled属性.我怎样才能做到这一点?

private function isUserAllowed (userName:Boolean):Boolean {
   if (userName == 'Tom')
      return true;
   if (userName == 'Bill')
      return false;
}

<mx:Button label="Create PO" id="createPOButton"
enabled="<I want to call isUserAllowed ('Bill') or isUserAllowed ('Tom') here>"
click="createPOButton_Click()" />
<mx:Button
enabled = "{this.myFunction(this.myVariable)}"
>

或内联:

<mx:Button
enabled = "{(function(arg:Object):Boolean{ ... })(this.myVariable)}"
>
相关文章
相关标签/搜索