我可以将 Flex 组件属性绑定到函数吗? [英] Can I bind a Flex component property to a function?

查看:32
本文介绍了我可以将 Flex 组件属性绑定到函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据具有一个或多个参数的函数的返回值在按钮上设置 enabled 属性.我该怎么做?

I want to set the enabled property on a button based on the return value of a function that has one or more parameters. How can I do this?

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)}"
>

这篇关于我可以将 Flex 组件属性绑定到函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆