Sunday, 7 December 2008

DataBinding in Flex

Flex let us use a very simple way to bind our data to the controls.
I will show just a very simple example first, more complicated examples will be add in future.
*Simple:
<mx:HBox> <mx:Text id="output" text="{input.text}"> </mx:Text> <mx:TextInput id="input"> </mx:TextInput> </mx:HBox>
The output text can updated instantly when you change the content in "input" TextInput control.

This is called inline data binding.Inline data binding represents the most limited use of ActionScript, because it can evaluate only one expression. For instance, the preceding example evaluates the expression input.text. You could use a more complex expression, such as the
following:
text="{'User input: ' + input.text}"

No comments: