added
Problem:
You have some custom initialization that you need to perform every time a component is added using a State, such as setting focus in a particular field. You need a reliable method of determining that the component has been added.
Solution:
There are two solutions that I've found to work in this case. This first is to add a new public method to the component called activate() and then call it from a handler on the enterState Event. The second is to listen to the addedToStage and updateComplete events, set a flag in addedToStage that you check in updateComplete to run your initialization.
Here is the code, example app, and more detailed explanation.
The added event is fired when a component is added as a child to another component. This is accomplished through the addChild(child:DisplayObject) method (or addChildAt(child:DisplayObject,pos:int)).
When the component is removed, it will receive the removed event. This is the complementary event to added.
