Flex 4.6 check if creationComplete has occured

actionscript-3, apache-flex, events, flash, flex4

Solution

I just Windows grepped 4.6 source and UIComponent dispatches creation complete event when initialized is set to true so http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIComponent.html#initialized should work.

EDIT In response to the comment initialize is called but set initialized to true doesn't occur at step 9 it's literally where the CREATION_COMPLETE is dispatched within UIComponent see this snippet I pulled from the 4.6 source of UIComponent:

/**
     *  A flag that determines if an object has been through all three phases
     *  of layout: commitment, measurement, and layout (provided that any were required).
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */

/**
 *  @private
 */

public function set initialized(value:Boolean):void
{
    _initialized = value;

    if (value)
    {
        setVisible(_visible, true);
        dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE));
    }
}

If you don't believe me hit Ctrl+Shift+T type in UIComponent and search for "Variables: Creation" you'll get a comment block that starts the section where the start-up events are dispatched and some variables for flagging those events being complete are set. INITIALIZE event happens in a different setter below the one I referenced.

public function set processedDescriptors(value:Boolean):void
{
    _processedDescriptors = value;

    if (value)
        dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
}

Problem

Within AS3, I know I can check if the stage is accessible to, say, an externally loaded SWF by including this at the beginning of the loaded SWF: ``` if (stage) { this.init(); } else { addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler); } ``` The above solution is great for checking if the stage is accessible to the program by the time these lines are executed, or adding an event listener to listen for when the stage is accessible. I am trying to replicate a similar situation within a custom component in Flex 4.6. However, instead of listening for the presence of the stage, I am looking for whether or not the `creationComplete` event for the component has been fired. Is there a similar solution for whether or not the `creationComplete` event has been fired, and listen for it if it hasn't been?

Original source