         // Call this method on each non-visual StyleClient
         if (advanceStyleClientChildren != null)
         {
-            var nAdvanceStyleChildern:int = advanceStyleClientChildren.length;
-            for (var j:int = 0; j < nAdvanceStyleChildern; j++)
+            for (var styleClient:Object in advanceStyleClientChildren)
             {
-                if (advanceStyleClientChildren[j].inheritingStyles !=
+                var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient
+                    as IAdvancedStyleClient;
+                
+                if (iAdvanceStyleClientChild && 
+                    iAdvanceStyleClientChild.inheritingStyles !=
                     StyleProtoChain.STYLE_UNINITIALIZED)
                 {
-                    advanceStyleClientChildren[j].regenerateStyleCache(recursive);
+                    iAdvanceStyleClientChild.regenerateStyleCache(recursive);
                 }
             }
         }
-
-    }
-
+    }
     /**
      *  This method is called when a state changes to check whether
      *  state-specific styles apply to this component. If there is a chance

     */
    public function removeStyleClient(styleClient:IAdvancedStyleClient):void
    {
        if(advanceStyleClientChildren && advanceStyleClientChildren.length != 0)
        {
            var i:int = advanceStyleClientChildren.indexOf(styleClient);
            if(i!=-1) {
                advanceStyleClientChildren.splice(i, 1);
                styleClient.styleParent = null;

                styleClient.regenerateStyleCache(true);

                styleClient.styleChanged(null);
            }
        }
    }
    


        if (advanceStyleClientChildren != null)
        {
            for (var styleClient:Object in advanceStyleClientChildren)
            {
                var iAdvanceStyleClientChild:IFlexModule = styleClient
                    as IFlexModule;
                
                if (iAdvanceStyleClientChild && 
                    (iAdvanceStyleClientChild.moduleFactory == null 
                        || iAdvanceStyleClientChild.moduleFactory == _moduleFactory))
                {
                    iAdvanceStyleClientChild.moduleFactory = factory;
                }
            }
        }
        _moduleFactory = factory;

        setDeferredStyles();
