 
 import mx.core.ILayoutElement;
 import mx.core.UIComponent;
+import mx.core.UIComponentGlobals;
 import mx.core.mx_internal;
+import mx.events.DynamicEvent;
 import mx.events.FlexEvent;
 import mx.managers.layoutClasses.PriorityQueue;
 

	/**
	 *  @private
	 */
	private function doPhasedInstantiation(event:Event = null):void
	{
        var sm:ISystemManager = SystemManagerGlobals.topLevelSystemManagers[0]
		sm.removeEventListener(Event.ENTER_FRAME, doPhasedInstantiation);


		listenersAttached = true;
	}

    private function doPhasedInstantiationCallback(event:Event):void
    {

        // At run-time, callLaterDispatcher2() is called
        // without a surrounding try-catch.
        if (!UIComponentGlobals.catchCallLaterExceptions)
        {
            doPhasedInstantiation();
        }

        // At design-time, callLaterDispatcher2() is called
        // with a surrounding try-catch.
        else
        {
            try
            {
                doPhasedInstantiation();
            }
            catch(e:Error)
            {
                var callLaterErrorEvent:DynamicEvent = new DynamicEvent("callLaterError");
                callLaterErrorEvent.error = e;
                var sm:ISystemManager = SystemManagerGlobals.topLevelSystemManagers[0]
                sm.dispatchEvent(callLaterErrorEvent);
            }
        }
    }

}

}
