Home > Uncategorized > Data Binding expressions

Data Binding expressions

In MXML, you may use expressions as a source of data binding.

Example:

<mx:Label text="Beer" visible="{age >= 18}" />

The Label will only be displayed if the person is 18 or older.

Did you try a more complex expression?

<mx:Label text="Beer" visible="{age >= 18 && gender == 'male'}" />

Ah ha! You get a compiler error. Why? Because you’re inside MXML and the & character is special.

Solution: replace the & with &amp;

<mx:Label text="Beer" visible="{age >= 18 && gender == 'male'}" />
Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Switch to our mobile site