P983
About data binding
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. Adobe Flex 2 provides three ways to
specify data binding: the curly braces ({}) syntax and the <mx:Binding> tag in MXML and
the BindingUtils methods in ActionScript.
數據綁定提供了一種便利的方法在程序中傳遞數據,它可以在一個對象和另一個對象間建立關聯關系。在Flex2中提供了三種特定的方法用于數據綁定:
1、{}
2、<mx:Binding>標簽
3、ActionScript中的BindingUtils方法
Common uses of data binding include the following:
通常使用數據綁定的情形如下:
■ To bind properties of user interface controls to data service requests.
將用戶交互界面中的輸入綁定到數據服務請求中。
■ To bind data service results to properties of user interface controls.
將數據服務響應的結果綁定到用戶交互界面中。
■ To bind data service results to a middle-tier data model, and to bind that data model’s
fields to user interface controls. For more information about data models, see Chapter 38,
“Storing Data,” on page 1001.
將數據服務響應結果綁定到處于中間層的數據模型中,再將數據模型的字段綁定到用戶交互界面中。
■ To bind properties of user interface controls to a middle-tier data model, and to bind that
data model’s fields bound to a data service request (a three-tier system).
984 Binding Data
將用戶交互界面中的輸入綁定到處于中間層的數據模型中,再將數據模型的字段綁定到數據服務請求中。
■ To bind an ArrayCollection or XMLListCollection object to the dataProvider property
of a List-based control.
將ArrayCollection或者XMLListCollection對象綁定到基于List的界面控件的dataProvider屬性中。
■ To bind individual parts of complex properties to properties of user interface controls. An
example would be a master-detail scenario in which clicking an item in a List control
displays data in several other controls.
將復雜屬性的單個部分綁定到用戶交互界面中。
■ To bind XML data to user interface controls by using ECMAScript for XML (E4X)
expressions in binding expressions.
通過使用ECMAScript for XML表達式將XML數據綁定到用戶交互界面中。
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, it would be preferable to use a method that assigns properties in order. Also,
binding executes every time a property changes, so it is not the best solution when you want
changes to be noticed only some of the time.
盡管數據綁定是一個強大的機制,但是其并不適用于所有狀況。比如在如下兩種情況中就不適合使用數據綁定:
1、在一個復雜的用戶交互界面中,一些更新有嚴格的時間次序。
2、由于數據綁定在屬性每次發生改變時都會觸發,僅僅希望在一些特定的條件下觸發改變時就不適合使用數據綁定。
posted on 2006-10-31 12:52
The Matrix 閱讀(293)
評論(0) 編輯 收藏 所屬分類:
Flex2