ActionScript 2.0 Components Language Reference |
|
|
|
| Data binding classes > Constructor for the Binding class | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
new Binding(source,destination, [format], [isTwoWay])
source A source 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 (see EndPoint class).
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 2.0 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.
Nothing.
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 |
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.
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"}});
|
|
|
|