User Guide
Data binding classes (Flash Professional only) 215
destination The destination endpoint of the binding. This parameter is nominally of type
mx.data.binding.EndPoint, but can be any ActionScript object that has the required Endpoint
fields.
format An optional object that contains formatting information. The object must have the
following properties:
• cls An ActionScript class that extends the class mx.data.binding.DataAccessor.
• settings An object whose properties provide optional settings for the formatter class
specified by
cls.
isTwoWay An optional Boolean value that specifies whether the new Binding object is
bidirectional (
true) or not (false). The default value is false.
Returns
Nothing.
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.
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()).
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 217.
import mx.data.binding.*;
var src = new EndPoint();