I want to reinitialize a component by clicking a button.I use the following code, but seem nothing is happening.
protected function createItem(event:MouseEvent):void
{
this.currentState="Viewer";
this.initialize();
}
Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually, there are much more steps than four to the Flex Component Lifecycle. See here and here for more information.
What you may mean is that there are four methods run as part of the Flex Component LifeCycle; and those are createChildren(), commitProperties(), updateDisplayList(), and measure(). In the MX architecture, there is also a layoutChrome() method, but that is not commonly used.
In Flex 4 Spark architecture; there are a lot of other hooks (partAdded(), partRemoved()) but they all extend off the MX Architecture.
You may benefit from using the invalidation methods:
In a Flex 4, Spark component, run invalidateSkinState() to force getCurrentSkinState() method to re-execute during the next render event.
You can also remove a component from the stage using removeChild()–removeElement() for Spark containers–and then addChild()–addElement for Spark containers. That would essentially force the component to re-start it’s process.
You could also create a brand new instance of the component and remove the old one.