Original (English): http://blogagic.com/18/flex-component-life-cycle
Now we have a good understanding of precompilation, but we don't have to be ready to start developing new flex components.
In any case, before developing a new component, we need a clear understanding of the Flex component's life cycle. A good understanding of the life cycle is useful for developing the right components.
The following code will have some different rationale for the elaboration, and there are comments below. Look at them with a "See Code sample" hyperlink. The resolution is seen through the "see Explanations".
The Flex component lifecycle is defined by the Flex framework and manages these components during application. More precisely, the life cycle is suitable for all objects inherited from UIComponent.
UIComponent is the base class for all graphical object elements (which can be rendered on the screen or manipulated by the user).
The UIComponent lifecycle consists of the following phases: Construct configuration initialization Validation---Commit three cases: Property change---------Size change------Drawing & Position ing changes
Split destroy
The following code example illustrates the prototype and principle of the uicomponent life cycle.
The following code samples illustrate the patterns and principles of the UIComponent life Cycle:flex Component Life Cycle Code Extracts Constructor Createchildren () Change (Setters, Invalidateproperties () and Commitproperties ()) Sizi Ng Change (invalidatesize () and measure ()) Drawing and positioning Change (invalidatedisplaylist () and Updatedisplaylist ( ))
1 constructors
A construct is the first phase of a component that begins when the constructor is called. We all already know what constructors and constructors are for. But in Flex, there are several important points that need to be emphasized.
A, super (), invokes the constructor of the parent class.
Although it is not necessary to call the constructor of the parent class (because the compiler will do it for you), it is better to call super () through the display.
b, no parameters for the constructor function
The constructor must not have the required parameters, the reason for this principle is that this component can be instantiated by as and Mxml. When a component is created from an mxml file, the constructor does not allow any parameters to be supplied.
So, if you want your component to be used in mxml, remember this principle.
c, the minimum amount of work and computation in the constructor
Unlike many other languages, Flex constructors do not have to be used to create instances or to build properties of components. The reason behind this rule is that when the constructor is called, it takes time to prepare the assembly. Some of its properties have not yet been created, and some of its properties and designs are changed by the quilt class, and the constructors do not benefit from the immediate compilation process.
Constructors are used to add listening events or to hardcode some properties. But you should not put too much, the less you work in your constructor and the better the calculation.