我可以绑定一个Flex组件的属性为一个函数? [英] Can I bind a Flex component property to a function?
本文介绍了我可以绑定一个Flex组件的属性为一个函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将的启用的基于一个函数,有一个或多个参数的返回值的按钮属性。我怎样才能做到这一点?
私有函数isUserAllowed(用户名:布尔):布尔{
如果(用户名=='汤姆')
返回true;
如果(用户名=='法案')
返回false;
}
< MX:按钮标签=创建采购订单ID =createPOButton
启用=<我想打电话给isUserAllowed('法案')或isUserAllowed('汤姆')这里>中
点击=createPOButton_Click()/>
解决方案
< MX:按钮
启用={this.myFunction(this.myVariable)}
>
或内嵌:
< MX:按钮
启用={(功能(ARG:对象):布尔{...})(this.myVariable)}
>
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)}"
>
or inline:
<mx:Button
enabled = "{(function(arg:Object):Boolean{ ... })(this.myVariable)}"
>
这篇关于我可以绑定一个Flex组件的属性为一个函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文