What is component life cycle in flex 4?
Component life cycle is the way in which in flex framework interacts with every component. It is set of methods the framework calls to instantiate, control and destroy components. They are method that takes the most of every frame.
Flex component life cycle: 3 stage
· Calls your constructor.
· Can access properties and methods of class but not its children as they are not created yet.
· Must be public and no return type.
· Call super()
· Not used often in flex.
· The process of assigning values to properties on objects
· This results in the first call to commitProperties();
· Containers must not expect children to be added yet.
· Adding a component to element list
· After attachment, components are initialized
· It involves several method calls and events dispatches.
· The invalidation process
o When a property is set, retain the value on a private variable
o Set a ‘dirty’ flag
o Invalidate the Component
· The validation process
o When the framework calls validation methods, updates your component accordingly.
o Ex . setting text on TextBase class.
· Invalidation Methods plays role here, called to “invalidate” a component, but not do any work on it.
· invalidateProperties() – any property changes
· invalidateSize() –change to width or height
· invalidateDisplayList() –change to child elements
· invalidateSkinState() – sets skinChanged property to true and calls invalidateProperties()
· “do the work” that invalidation requires move things, add things and remove things etc.
· Methods called are
o commitProperties()- all changes based on property and data events go here
o getCurrentSkinState()- used if the current skin state need to be updated
o updateDisplayList() – used when elements on display list need to be drawn.
o measure()- caluculate the size of components
· It puts off the “real work” until the appropriate time.
· In this phase component assigns handlers to user events
· Process things and cause invalidation to occur
· This refers to the process of removing components from the element list.
· These component can be re-parented( come back to live) or abandoned to die.
· Any object in the element list with no active reference is eligible for garbage collection.