Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 160

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Changing the alignment of text in a control does not necessarily change the control's size.
However, if it does, include a call to the
method.
The main advantages of using the
To coordinate the modifications of multiple properties so that the modifications occur
synchronously.
For example, you might define multiple properties that control the text displayed by the
component, such as the alignment of the text within the component. A change to either
the text or the alignment property requires Flex to update the appearance of the
component. However, if you modify both the text and the alignment, you want Flex to
perform any calculations for sizing or positioning the component once, when the screen
updates.
Therefore, you use the
relationship of multiple component properties. By coordinating the property changes in
the
commitProperties()
To coordinate multiple modifications to the same property.
You do not necessarily want to perform a complex calculation every time a user updates a
component property. For example, users modify the
to change the image displayed in the button. Calculating the label position based on the
presence or size of an icon can be a computationally expensive operation that you want to
perform only when necessary.
To avoid this behavior, you use the
calculations. Flex calls the
That means you perform the calculations once when Flex updates the screen, regardless of
the number of times the property changed between screen updates.
The following example shows how you can handle two related properties in the
commitProperties()
// Define a private variable for the text property.
private var _text:String = "ModalText";
private var bTextChanged:Boolean = false;
// Define the getter method.
public function get text():String {
return _text;
}
//Define the setter method to call invalidateProperties()
// when the property changes.
public function set text(t:String):void {
_text = t;
160
Creating Advanced Visual Components in ActionScript
invalidateSize()
commitProperties()
commitProperties()
method, you can reduce unnecessary processing overhead.
commitProperties()
commitProperties()
method:
method to trigger the
method are the following:
method to calculate any values based on the
property of the Button control
icon
method to perform the
method when it updates the display.
measure()

Advertisement

Table of Contents
loading

Table of Contents