MXML: “true && true” error
Stumbled across this strange error while doing some development. I’ve needed to determine the enable function of a button based on two boolean conditions and as a result created the following bit of code:
<com:Component enabled=”{booleanA && booleanB}”/>
The compiler didn’t like what I’ve put together and threw the following error: The entity name must immediately follow the ‘&’ in the entity reference.
At first I litteraly thought that I’ve forgotten how to code and trivially tried a simple if statement in a <fx:Script> tag – that worked without a problem. I’ve also tried to see if the or ”||” operator worked within the enabled attribute – which it did. My last thought before searching for a solution online was that the latest version of Adobe Flex had a bug in it.
Some of the solution that I’ve discovered are:
- use ;& instead
- use (booleanA) ? (booleanB):false
- use !(!active1 || !active2)
Tags: coding, Flex, programming