Flex failure mechanism, failure method, failure phase

Source: Internet
Author: User

I. What is the invalidation mechanism?

Flex uses the invalidation mechanism to synchronize component changes. Flex calls a series of methods. For example, it monitors a change variable in the setter method to mark that something of the component has changed, and then in the next "render event) "trigger the commitproperties (), measure (), layoutchrome (), updatedisplaylist () of the component to check these Boolean variables to complete the final change logic. The additional advantage of doing so is that the setter method can return more quickly, leaving the processing of the new attribute value to the commitproperties () method.

 

Ii. Why is the invalidation mechanism used?

One case is that when multiple attributes of a component are set, such as the label and icon attributes of the button control, we need to execute commitproperties () at one time after all attributes are set (), the measure () and updatedisplaylist () methods, instead of setting the label attribute and then executing these methods again after setting the icon attribute.

In another case, several components change their font size at the same time. The program can change the font size much faster than the flex update application. Therefore, the layout must be updated after the final font change is determined. In addition, flex needs to coordinate layout operations to eliminate any redundancy process, rather than performing a layout operation after each component updates its font size.

 

3. Contact for failure Methods

The failure Method and Its Trigger functions are as follows:
1. invalidateproperties () Notification component, so that its commitproperties () method is called when the screen is updated next time.

2. invalidatesize () Notification component to call its measure () method when the screen is updated next time.

3. The invalidatedisplaylist () Notification component allows the layoutchrome () method and updatedisplaylist () method of the next screen update to be called.

When a component calls an "invalid" method, it notifies flex that the component has been updated. When multiple components fail to be called
Method. Flex will coordinate these updates in schedules so that these updates can be executed together during the next screen update. Note that createchildren () does not have an expiration method. It will be executed immediately after the call.

 

4. We can follow the following rules in the cycle::

1. If the attribute needs to change an attribute of the Child component, call invalidateproperties () and rewrite the commitproperties () method.

2. If the attribute needs to change some visible content on the current component, call the invalidatedisplaylist () method and rewrite the updatedisplaylist () method.

3. If the attribute affects the component size, call the invalidatesize () method and override the measure () method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.