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

How to bind variables to Flex data

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

Share

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

Editor to share with you how to make variables for Flex data binding, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Flex data binding

The knowledge about Flex data binding is collected and sorted out:

Flex data binding makes it easy and convenient to transfer data between different layers in an application by associating source attributes with target attributes. When the value of the source property is updated, an event is generated to notify the destination property to update.

When a variable is marked as bindable, other objects can modify the values of other destination properties of the variable. To bind Flex data on a variable, you must define the [Bindable] tag in one of the following three ways.

◆ before the definition of a class

Packagecom.oreilly.flexcookbook {i importflash.events.EventDispatcher; [Bindable] publicclassDataObjectextendsEventDispatcher {}}

◆ adds the [Bindable] tag before a class is created to create a binding expression so that all common properties of the class can be bound. All classes that can be bound must be implemented by the IEventDispatcher class because Flex data binding is event-driven to copy source data to destination data.

. Declare in front of the variable

[Bindable] privatevar_lastName:String; [Bindable] protectedvar_age:Number; [Bindable] publicvarfirstName:String

When a variable declared private is marked as bindable, it can only be bound in the class. Protected variables are only visible in inheritance or in the class itself. The common variables are visible.

◆ reverses the binding in front of the property through the implicit getter/setter method:

Privatevar_lastName:String;... [Bindable] publicfunctiongetlastName (): String {return_lastName;} p publicfunctionsetlastName (str:String): void {_ lastName=str;}

When you define the implied getter/setter as a bindable method by adding a [Bindable] tag at the top of the getter declaration, the variable can be accessed through dot syntax. So you can save it through the same grammar.

Take unbound variables, own variables, etc., to set up data source binding.

◆ is inside the framework, and when the value of the bound variable is updated, the framework sends a propertyChange event to update the data.

The [Bindable] tag accepts an event attribute by defining a custom event type:

[Bindable (event= "myValueChanged")]

By default, the event property is set to propertyChange. If you do not change the event type, the destination variable will be prompted internally using that type. If you customize this property, you must declare it inside the class.

Binding is implemented through event notification and is triggered when the source variable in the application is modified or initialized.

You can enforce the execution of Flex data binding for objects whose targets are mx.core.UIComponent subclasses by executing binding methods.

The above is all the contents of the article "how to make variables Flex data binding". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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