PDA

View Full Version : Binding Enabled to a function


captainjon
11-30-2007, 10:09 AM
Hello,

I want to bind a function to the enabled state of a button, but when
I do, it doesnt work. I can put an expression into the binding like
{list.selectedIndex > -1} and this is fine but I need to put multiple
expressions and it doesnt like && in the binding string.
How can I use a function here (or multiple expressions) ?

thanks,

Jon

captainjon
11-30-2007, 10:10 AM
let me just add that the function only seems to execute once at creation time and just uses that value.

jimmy5804
11-30-2007, 04:28 PM
It is easy to bind to a function as long as the function takes a parameter you want to watch. (e.g. <mx: .... enabled="{isEnabled(myObj.myVar)}"... />") The function will be called every time the function parameter changes. You can also bind to a function that takes no parameters, but you have to create and dispatch your own event and it's usually more work than it's worth IMO.

captainjon
12-10-2007, 09:26 AM
thanks, I'll give that a go