Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the Flex binding mechanism?

Shulou Source: shulou.com Published: 2022-06-02 08:04:26 10月04日 Update

This article mainly introduces what the Flex binding mechanism is, the article is very detailed, has a certain reference value, interested friends must read it!

Flex binding mechanism

After we understand the event mechanism, it is not difficult to understand Flex binding. Flex binding is actually the application of the event mechanism.

1. What is Flex binding

The principle of Flex binding mechanism is events, which adds listening for change events on objects bound by Flex. Once a Flex bound object is changed, it will distribute a "propertyChange" event (default, it can also be changed to a self-defined event). In other components, there will be propertyChange event listening. When the event is captured, it will update the properties of the component and display it.

The purpose of the Flex binding is to Flex the variables, classes, methods, and so on in the Flex to the values of the component. For example, if a variable is bound by Flex, the relevant properties of the component referencing the variable will also change. Let's use an example to show

The effect of the above program is that when you click button, button does not directly change the selected state of checkbox, but changes the variable isSelected, because isSelected is bound by Flex, then it will change the selected state of CheckBox.

This seems a bit superfluous, and you can change the selected property of checkbox directly. I'm just trying to demonstrate the effect. If you have hundreds of checkbox dynamically constructed, you are not going to change them one by one.

◆ therefore, most of us declare a data source with Flex binding, so that controls that reference the data source, such as datagrid, refresh the list data even if you don't reset the dataProvider when the data source changes. Of course, there are many applications waiting for you to try.

What happens if the declaration of [Bindable] is removed from this code? Won't isSelected change?

IsSelected will change, and the result of our alert will also show that the result has changed, but the selection status of checkbox will not change, because when a component is created and finally displayed, it goes through many methods, such as addChild,commitProperties,updateDisplayList, etc. UpdataDisplayList is similar to refreshing the display effect.

Just change the property without updating the display, and the component will not change as a result of the property change.

The principle of Flex binding mechanism is also the use of event distribution, more complex Flex binding for you to discover.

The above is all the content of the article "what is the Flex binding mechanism?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Events mechanisms components properties variables effects data data sources methods states contents principles objects that is articles results updates monitoring complexity superfluous Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi macOS Shulou Technology Docker