      */
     mx_internal function clearFreeRenderers():void
     {
-        const freeRenderersLength:int = freeRenderers.length;
-        for (var i:int = 0; i < freeRenderersLength; i++)
-            freeRenderers[i] = null;
-        freeRenderers.length = 0;
+        resetFreeRenderers();
     }
     
     /**

    private static const LAYERING_ENABLED:uint =    0x1;
    private static const LAYERING_DIRTY:uint =      0x2;
    
    //--------------------------------------------------------------------------
    //
    //  Overridden properties

    //--------------------------------------------------------------------------
    
    /**
     *  Return the item renderer factory for the specified item, if any.  Prefer 
     *  itemRendererFunction over itemRenderer.
     */
    private function itemToRendererFactory(item:Object):IFactory
    {
        if (itemRendererFunction != null)
            return itemRendererFunction(item);
        
        return itemRenderer;
    }
    
    /**
     *  Return a new renderer created with the specified factory and add an entry for it
     *  to rendererToFactoryMap so that we can free and allocate it later.
     */
    private function createRenderer(factory:IFactory):IVisualElement
    {
        const element:IVisualElement = factory.newInstance() as IVisualElement;
        rendererToFactoryMap[element] = factory;
        return element;
    }
    
    /**
     *  If a vector of free renderers exists for the specified factory, remove 
     *  one and return it.
     */
    private function allocateRenderer(factory:IFactory):IVisualElement
    {
        const renderers:Vector.<IVisualElement> = freeRendererMap[factory] as Vector.<IVisualElement>;
        if (renderers)
        {
            const element:IVisualElement = renderers.pop();
            if (renderers.length == 0)
                delete freeRendererMap[factory];
            if (element)
                return element;
        }
        
        return null;
    }
    
    /**
     *  Add the specified renderer to the rendererToFactoryMap.
     */
    private function freeRenderer(renderer:IVisualElement):void
    {
        if (!renderer)
            return;
        
        const factory:IFactory = rendererToFactoryMap[renderer]; 
        if (!factory)
            return;
        
        var freeRenderers:Vector.<IVisualElement> = freeRendererMap[factory];
        if (!freeRenderers)
        {
            freeRenderers = new Vector.<IVisualElement>();
            freeRendererMap[factory] = freeRenderers;            
        }
        freeRenderers.push(renderer);
    }
    
    /** 
     *  @private
     *  Return a vector of all of the renderers in freeRendererMap.
     */
    private function allFreeRenderers():Vector.<IVisualElement>
    {
        const rv:Vector.<IVisualElement> = new Vector.<IVisualElement>();
        
        for each (var v:Vector.<IVisualElement> in freeRendererMap)
        {
            for each (var e:IVisualElement in v)
                rv.push(e);
        }
        
        return rv;
    }
    
    /**
     *  @private
     *  Reset the private free renderers data.
     */
    private function resetFreeRenderers():void
    {
        rendererToFactoryMap = new Dictionary(true);
        freeRendererMap = new Dictionary();
    }
    
    /**
     *  @private
     *  Throw an error which indicates that we were unable to create an item renderer
     *  for the specified dataProvide and we weren't able to use the item as an 
     *  item renderer.
     */
    private function throwCreateRendererFailedError(item:Object):void
    {
        var err:String;
        if (item is IVisualElement || item is DisplayObject)
            err = resourceManager.getString("components", "cannotDisplayVisualElement");
        else
            err = resourceManager.getString("components", "unableToCreateRenderer", [item]);
        
        throw new Error(err);
    }          
    
    /**
     *  @private
     *  Create or reuse an item renderer for the specified dataProvider item.  This method is 
     *  used by getVirtualLayoutElementAt(), i.e. when useVirtualLayout=true.
     * 
     *  This method actually "returns" two values: the renderer itself and a flag that indicates
     *  if the renderer was newly added.   The second value is actually just a variable.  Each  
     *  time this method is called it sets addedVirtualRenderer.
     */
    private function createVirtualRendererForItem(item:Object, failRTE:Boolean=true):IVisualElement
    {
        var renderer:IVisualElement = null;
        
        const rendererFactory:IFactory = itemToRendererFactory(item);
        if (rendererFactory)
            renderer = allocateRenderer(rendererFactory);  // use a free renderer

        if (!renderer && rendererFactory)
        {
            renderer = createRenderer(rendererFactory);
            addedVirtualRenderer = true;
        }
        
        if (!renderer && (item is IVisualElement) && (item is DisplayObject))
        {
            renderer = IVisualElement(item);
            addedVirtualRenderer = true;            
        }
        
        if (!renderer && failRTE)
            throwCreateRendererFailedError(item);
        
        return renderer;
    }
            
    /**
     *  @private
     *  Create an item renderer for the specified dataProvider item.   This method is used
     *  when useVirtualLayout=false.
     */
    private function createRendererForItem(item:Object, failRTE:Boolean=true):IVisualElement
    {
        var renderer:IVisualElement = null;
        
        const rendererFactory:IFactory = itemToRendererFactory(item);
        if (rendererFactory)
            renderer = createRenderer(rendererFactory);
        
        if (!renderer && (item is IVisualElement) && (item is DisplayObject))
            renderer = IVisualElement(item);
        
        if (!renderer && failRTE)
            throwCreateRendererFailedError(item);      

        return renderer;
    }
    
    /** 
