随笔-75  评论-193  文章-5  trackbacks-0
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 阅读(268) 评论(0)  编辑  收藏 所属分类: Flex2

只有注册用户登录后才能发表评论。


网站导航: