User Guide
210 Data binding classes (Flash Professional only)
Description
Constructor; creates a new Binding object. You can bind data to any ActionScript object that
has properties and emits events including, but not limited to, components.
A binding object exists as long as the innermost movie clip contains both the source and
destination components. For example, if movie clip named A contains components X and Y,
and there is a binding between X and Y, then the binding is in effect as long as movie clip
A exists.
Example
In this example, the text property of a TextInput component (src_txt) is bound to the text
property of another TextInput component (
dest_txt). When the src_txt text field loses
focus (that is, when the
focusOut event is generated), the value of its text property is copied
into
dest_txt.text.
import mx.data.binding.*;
var src = new EndPoint();
src.component = src_txt;
src.property = "text";
src.event = "focusOut";
var dest = new EndPoint();
dest.component = dest_txt;
dest.property = "text";
new Binding(src, dest);
The following example demonstrates how to create a Binding object that uses a custom
formatter class. For more information, see “CustomFormatter class (Flash Professional only)”
on page 212.
import mx.data.binding.*;
var src = new EndPoint();
src.component = src_txt;
src.property = "text";
src.event = "focusOut";
var dest = new EndPoint();
dest.component = text_dest;
dest.property = "text";
new Binding(src, dest, {cls: mx.data.formatters.Custom, settings:
{classname: "com.mycompany.SpecialFormatter"}});
NOTE
It’s not necessary to retain a reference to the new Binding object. As soon as the Binding
object is created, it immediately begins listening for “changed” events emitted by either
endpoint. In some cases, however, you might want to save a reference to the new
Binding object, so that you can call its
execute() method at a later time (see
Binding.execute()).