Multiple Conditions in mxml (using symbols like &)

This post was moved to http://srinichekuri.com/2011/02/12/multiple-conditions-in-mxml-using-symbols-like/

******************************************************************

Often we try to put in conditions to enable/disable components in mxml. Its straight forward if we have one condition to do this.
For eg:

<s:Button enable={flag1} label="Test Button"/>

But if we want to put in multiple conditions then we will run into compiler errors if we use symbols (like &(AND), although |(OR) seems fine).
For eg:

<s:Button enable={flag1&&flag2} label="Test Button"/>

Here is the solution for this. Instead of putting the condition we can put in the condition in a function and bind the function.
For eg:
mxml:

<s:Button enable={enableButton()} label="Test Button"/>

function:

private function enableButton():Boolean{	return flag1&&flag2;}
Advertisements