Data binding (Flash Professional only) 395
In the Flash interface, you bind data by using the Bindings and Schema tabs of the
Component inspector. Although you need to understand how bindings and schemas work in
Flash, your connector component is usually the first component you need to set up, because it
brings in the schema for your data source; see “Data connectivity (Flash Professional only)”
on page 412.
Data binding is supported only between components that exist in Frame 1 of the main
Timeline, Frame 1 of a movie clip, or Frame 1 of a screen.
You can also create runtime bindings by writing ActionScript code. For more information, see
“Data binding classes (Flash Professional only)” in the Components Language Reference.
A simple binding example
The following procedure provides a simple illustration of how data binding connects one UI
component to another. In the example, the value properties of component instances
stepper1_nm and stepper2_nm are bound to each other, and the value properties of
stepper3_nm and myInput_txt are bound to each other. In a real-world application, you
would most likely import a schema, define additional bindable component properties, and
create multiple bindings between data components and UI components.
To connect UI components to create data binding:
1. Add a NumericStepper component to the Stage, and name it stepper1_nm.
2. Add another NumericStepper component, and name it stepper2_nm.
3. With stepper1_nm selected, open the Component inspector, and click the Bindings tab.
4. Click the Add Binding (+) button to add a binding.
5. In the Add Binding dialog box, select Value, and click OK.
6. In the Name/Value section at the bottom of the Bindings tab, click the Bound To
item under Name, and click the magnifying glass icon across from the Bound To item
under Value.
7. In the Bound To dialog box, select component stepper2_nm under Component Path, and
click OK.
8. Select Control > Test Movie. Click the Up and Down buttons on component
stepper1_nm.
Each time you click the buttons on stepper1_nm, the value property of stepper1_nm is
copied to the
value property of stepper2_nm. Each time you click the buttons on
stepper2_nm, the value property of stepper2_nm is copied to the value property of
stepper1_nm.