  */
 public class LayoutManager extends EventDispatcher implements ILayoutManager
 {
-    include "../core/Version.as";
-
-    //--------------------------------------------------------------------------
-    //
-    //  Class variables
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  @private
-     *  The sole instance of this singleton class.
+	include "../core/Version.as";
+
+	//--------------------------------------------------------------------------
+	//
+	//  Class variables
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  @private
+	 *  The sole instance of this singleton class.
      */
-    private static var instance:LayoutManager;
-
-    //--------------------------------------------------------------------------
-    //
-    //  Class methods
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  Returns the sole instance of this singleton class,
-     *  creating it if it does not already exist.
-     *
-     *  @return Returns the sole instance of this singleton class,
-     *  creating it if it does not already exist.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Flex 3
-     */
-    public static function getInstance():LayoutManager
-    {
-        if (!instance)
-            instance = new LayoutManager();
-
-        return instance;
-    }
-
-    //--------------------------------------------------------------------------
-    //
-    //  Constructor
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  Constructor.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Flex 3
-     */
-    public function LayoutManager()
-    {
-        super();
+	private static var instance:LayoutManager;
+
+	//--------------------------------------------------------------------------
+	//
+	//  Class methods
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Returns the sole instance of this singleton class,
+	 *  creating it if it does not already exist.
+         *
+         *  @return Returns the sole instance of this singleton class,
+	 *  creating it if it does not already exist.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+	public static function getInstance():LayoutManager
+	{
+		if (!instance)
+			instance = new LayoutManager();
+
+		return instance;
+	}
+
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Constructor.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function LayoutManager()
+	{
+		super();
 
         systemManager = SystemManagerGlobals.topLevelSystemManagers[0];
-    }
-    
-    //--------------------------------------------------------------------------
-    //
-    //  Variables
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  @private
-     *  A queue of objects that need to dispatch updateComplete events
-     *  when invalidation processing is complete
-     */
-    private var updateCompleteQueue:PriorityQueue = new PriorityQueue();
-
-    /**
-     *  @private
-     *  A queue of objects to be processed during the first phase
-     *  of invalidation processing, when an ILayoutManagerClient  has
-     *  its validateProperties() method called (which in a UIComponent
-     *  calls commitProperties()).
-     *  Objects are added to this queue by invalidateProperties()
-     *  and removed by validateProperties().
-     */
-    private var invalidatePropertiesQueue:PriorityQueue = new PriorityQueue();
-
-    /**
-     *  @private
-     *  A flag indicating whether there are objects
-     *  in the invalidatePropertiesQueue.
-     *  It is set true by invalidateProperties()
-     *  and set false by validateProperties().
-     */
-    private var invalidatePropertiesFlag:Boolean = false;
-
-    // flag when in validateClient to check the properties queue again
-    private var invalidateClientPropertiesFlag:Boolean = false;
-
-    /**
-     *  @private
-     *  A queue of objects to be processed during the second phase
-     *  of invalidation processing, when an ILayoutManagerClient  has
-     *  its validateSize() method called (which in a UIComponent
-     *  calls measure()).
-     *  Objects are added to this queue by invalidateSize().
-     *  and removed by validateSize().
-     */
-    private var invalidateSizeQueue:PriorityQueue = new PriorityQueue();
-
-    /**
-     *  @private
-     *  A flag indicating whether there are objects
-     *  in the invalidateSizeQueue.
-     *  It is set true by invalidateSize()
-     *  and set false by validateSize().
-     */
-    private var invalidateSizeFlag:Boolean = false;
-
-    // flag when in validateClient to check the size queue again
-    private var invalidateClientSizeFlag:Boolean = false;
-
-    /**
-     *  @private
-     *  A queue of objects to be processed during the third phase
-     *  of invalidation processing, when an ILayoutManagerClient  has
-     *  its validateDisplayList() method called (which in a
-     *  UIComponent calls updateDisplayList()).
-     *  Objects are added to this queue by invalidateDisplayList()
-     *  and removed by validateDisplayList().
-     */
-    private var invalidateDisplayListQueue:PriorityQueue = new PriorityQueue();
-
-    /**
-     *  @private
-     *  A flag indicating whether there are objects
-     *  in the invalidateDisplayListQueue.
-     *  It is set true by invalidateDisplayList()
-     *  and set false by validateDisplayList().
-     */
-    private var invalidateDisplayListFlag:Boolean = false;
-
-    /**
-     *  @private
-     */
-    private var waitedAFrame:Boolean = false;
-
-    /**
-     *  @private
-     */
-    private var listenersAttached:Boolean = false;
-
-    /**
-     *  @private
-     */
-    private var originalFrameRate:Number;
-
-    /**
-     *  @private
-     *  used in validateClient to quickly estimate whether we have to
-     *  search the queues again
-     */
-    private var targetLevel:int = int.MAX_VALUE;
+	}
+	
+	//--------------------------------------------------------------------------
+	//
+	//  Variables
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  @private
+	 *  A queue of objects that need to dispatch updateComplete events
+	 *  when invalidation processing is complete
+	 */
+	private var updateCompleteQueue:PriorityQueue = new PriorityQueue();
+
+	/**
+	 *  @private
+	 *  A queue of objects to be processed during the first phase
+	 *  of invalidation processing, when an ILayoutManagerClient  has
+	 *  its validateProperties() method called (which in a UIComponent
+	 *  calls commitProperties()).
+	 *  Objects are added to this queue by invalidateProperties()
+	 *  and removed by validateProperties().
+	 */
+	private var invalidatePropertiesQueue:PriorityQueue = new PriorityQueue();
+
+	/**
+	 *  @private
+	 *  A flag indicating whether there are objects
+	 *  in the invalidatePropertiesQueue.
+	 *  It is set true by invalidateProperties()
+	 *  and set false by validateProperties().
+	 */
+	private var invalidatePropertiesFlag:Boolean = false;
+
+	// flag when in validateClient to check the properties queue again
+	private var invalidateClientPropertiesFlag:Boolean = false;
+
+	/**
+	 *  @private
+	 *  A queue of objects to be processed during the second phase
+	 *  of invalidation processing, when an ILayoutManagerClient  has
+	 *  its validateSize() method called (which in a UIComponent
+	 *  calls measure()).
+	 *  Objects are added to this queue by invalidateSize().
+	 *  and removed by validateSize().
+	 */
+	private var invalidateSizeQueue:PriorityQueue = new PriorityQueue();
+
+	/**
+	 *  @private
+	 *  A flag indicating whether there are objects
+	 *  in the invalidateSizeQueue.
+	 *  It is set true by invalidateSize()
+	 *  and set false by validateSize().
+	 */
+	private var invalidateSizeFlag:Boolean = false;
+
+	// flag when in validateClient to check the size queue again
+	private var invalidateClientSizeFlag:Boolean = false;
+
+	/**
+	 *  @private
+	 *  A queue of objects to be processed during the third phase
+	 *  of invalidation processing, when an ILayoutManagerClient  has
+	 *  its validateDisplayList() method called (which in a
+	 *  UIComponent calls updateDisplayList()).
+	 *  Objects are added to this queue by invalidateDisplayList()
+	 *  and removed by validateDisplayList().
+	 */
+	private var invalidateDisplayListQueue:PriorityQueue = new PriorityQueue();
+
+	/**
+	 *  @private
+	 *  A flag indicating whether there are objects
+	 *  in the invalidateDisplayListQueue.
+	 *  It is set true by invalidateDisplayList()
+	 *  and set false by validateDisplayList().
+	 */
+	private var invalidateDisplayListFlag:Boolean = false;
+
+	/**
+	 *  @private
+	 */
+	private var waitedAFrame:Boolean = false;
+
+	/**
+	 *  @private
+	 */
+	private var listenersAttached:Boolean = false;
+
+	/**
+	 *  @private
+	 */
+	private var originalFrameRate:Number;
+
+	/**
+	 *  @private
+	 *  used in validateClient to quickly estimate whether we have to
+	 *  search the queues again
+	 */
+	private var targetLevel:int = int.MAX_VALUE;
 
     /**
      *  @private

     */
    private var systemManager:ISystemManager;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  usePhasedInstantiation
    //----------------------------------

    /**
     *  @private
     *  Storage for the usePhasedInstantiation property.
     */
    private var _usePhasedInstantiation:Boolean = false;

    /**
     *  A flag that indicates whether the LayoutManager allows screen updates
     *  between phases.
     *  If <code>true</code>, measurement and layout are done in phases, one phase
     *  per screen update.
     *  All components have their <code>validateProperties()</code> 
     *  and <code>commitProperties()</code> methods 
     *  called until all their properties are validated.  
     *  The screen will then be updated.  
     * 
     *  <p>Then all components will have their <code>validateSize()</code> 
     *  and <code>measure()</code>
     *  methods called until all components have been measured, then the screen
     *  will be updated again.  </p>
     *
     *  <p>Finally, all components will have their
     *  <code>validateDisplayList()</code> and 
     *  <code>updateDisplayList()</code> methods called until all components
     *  have been validated, and the screen will be updated again.  
     *  If in the validation of one phase, an earlier phase gets invalidated, 
     *  the LayoutManager starts over.  
     *  This is more efficient when large numbers of components
     *  are being created an initialized.  The framework is responsible for setting
     *  this property.</p>
     *
     *  <p>If <code>false</code>, all three phases are completed before the screen is updated.</p>
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function get usePhasedInstantiation():Boolean
    {
        return _usePhasedInstantiation;
    }

    /**
     *  @private
     */
    public function set usePhasedInstantiation(value:Boolean):void
    {
        if (_usePhasedInstantiation != value)
        {
            _usePhasedInstantiation = value;

            // While we're doing phased instantiation, temporarily increase
            // the frame rate.  That will cause the enterFrame and render
            // events to fire more promptly, which improves performance.
            try {
                // can't use FlexGlobals here.  It may not be setup yet
                var stage:Stage = systemManager.stage;
                if (stage)
                {
                    if (value)
                    {
                        originalFrameRate = stage.frameRate;
                        stage.frameRate = 1000;
                    }
                    else
                    {
                        stage.frameRate = originalFrameRate;
                    }
                }
            }
            catch (e:SecurityError)
            {
                // trace("ignoring security error changing the framerate " + e);
            }
        }
    }

    //----------------------------------
    //  debugHelper

        }
    }

	private var _usingBridge:int = -1;

	/**
	 *  @private
	 */
    private function usingBridge(sm:ISystemManager):Boolean
	{
		if (_usingBridge == 0) return false;
		if (_usingBridge == 1) return true;

		if (!sm) return false;

		// no types so no dependencies
		var mp:Object = sm.getImplementation("mx.managers::IMarshalSystemManager");
		if (!mp)
		{
			_usingBridge = 0;
			return false;
		}
		if (mp.useSWFBridge())
		{
			_usingBridge = 1;
			return true;
		}
		_usingBridge = 0;
		return false;
	}

}

}

