Binding data

Data binding is the process of tying the data in one object to another object. It provides a convenient way to pass data around in an application. Flex provides two ways to specify data binding: the curly braces ({}) syntax and the <mx:Binding> tag.

Common uses of data binding include the following:

Although binding is a powerful mechanism, it is not appropriate for all situations. For example, for a complex user interface in which individual pieces must be updated based on strict timing, you could use a method that assigns properties in order. Also, since binding executes every time a property changes, it is not the best solution when you only want changes to be noticed some of the time.

Data binding requires a source property, a destination property, and a trigger that indicates when to copy the data from the source to the destination. The following example shows a Text control that gets its data from Slider control's value property. The property name inside the curly braces ({ }) is a binding expression that copies the value of the source property, mySlider.value, into the Text control's text property.

<mx:Slider id="mySlider"/>
<mx:Text text="{mySlider.value}"/>

You can bind to all types of properties, including properties of type Function. Binding occurs under the following circumstances:


Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000688.htm