How to enable/disbale a button in mxml depending on whether count is less than 10 or not
I am trying to bind enabled property of my button to the maximum value that an integer can attain. I need this button to allow user to view next page and want to disable this button when all the components have been shown (as reflected in count).
Something like :
<mx:Button label="Previous" click="nextHandler()" enabled="{count< 10}">
But the compiler is throwing an err开发者_运维问答or that '<' attribute can not be used in enabled tag.
Any ideas over this ?
Thanks in advance.
The following will work:
<mx:Button label="Previous" click="nextHandler()" enabled="{count < 10}"/>
Just tested it with:
<s:NumericStepper id="count"/>
<mx:Button label="Previous" enabled="{count.value < 10}"/>
Adrnans answer is spot on, but if you dont wish to use the XML/Html "<"; then the following also works:)
<mx:NumericStepper id="count" x="10" y="15" maximum="20"/>
<mx:Button label="Previous" enabled="{count.value >= 10 ? false : true}" x="10" y="45"/>
精彩评论