Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What methods does Adobe Flex provide to specify Flex data binding

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces what methods Adobe Flex provides to specify Flex data binding, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Let's focus on Flex data binding. Adobe Flex provides three ways to specify Flex data binding: braces ({}) syntax in MXML, tags in MXML, and a series of methods for BindingUtils in ActionScript.

About Flex data binding

Flex data binding is the process of associating data in one object with data in another object. Flex data binding provides a convenient way to transfer data between different layers of an application. Flex data binding requires a source attribute, a destination attribute, and a trigger event that indicates when data is copied from the source attribute to the destination attribute. When the source property changes, the object emits a trigger event.

Adobe Flex provides three methods for specifying Flex data bindings: braces ({}) syntax in MXML, tags in MXML, and a series of methods for BindingUtils in ActionScript.

(1) the following example uses curly braces ({}) syntax to show a Text control whose data comes from the TextInput control Text property:

ActionScript code and E4X expressions can be included as part of an Flex data binding expression, as shown in the following example:

(2) use markers as an alternative to curly braces syntax.

When you use it, you provide the tag with a source attribute as the tag's source attribute and a destination attribute as the tag's destination attribute. The following example uses tags to define an Flex data binding from a TextInput control to a Text control:

Compared with the brace syntax, the view (user interface) can be completely separated from the model with tags.

Tags can also bind multiple source attributes to the same destination attribute because multiple tags with the same destination attribute can be defined.

Curly braces syntax and tags can define Flex data bindings at compile time, while ActionScript code can define Flex data bindings at run time, as shown in the following example:

(3) create an attribute to be used as the source of Flex data binding

When you create a property to bind the expression source, Flex can automatically copy the value to all destination properties when the value of the source property changes. In order for Flex to perform a copy, you must use the [Bindable] tag to register this attribute with Flex.

The The [Bindable] metadata tag has the following syntax:

[Bindable] [Bindable (event= "eventname")]

If the event name is ignored, Flex automatically creates an event called propertyChange, and when the property changes, Flex issues the event to trigger all Flex data bindings that use this property as the source.

The following example makes a source where a maxFontSize property and a minFontSize property variable can be used for Flex data-binding expressions:

On which methods Adobe Flex provides to specify Flex data binding is shared here. I hope the above content can be helpful to you and you can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report