         }
 
         // Propagate moduleFactory to the child, but don't overwrite an existing moduleFactory.
-        if (child is UIComponent && UIComponent(child).moduleFactory == null)
+        if (child is IFlexModule && IFlexModule(child).moduleFactory == null)
         {
             if (moduleFactory != null)
-                UIComponent(child).moduleFactory = moduleFactory;
+                IFlexModule(child).moduleFactory = moduleFactory;
 
             else if (document is IFlexModule && document.moduleFactory != null)
-                UIComponent(child).moduleFactory = document.moduleFactory;
-
-            else if (parent is UIComponent && UIComponent(parent).moduleFactory != null)
-                UIComponent(child).moduleFactory = UIComponent(parent).moduleFactory;
+                IFlexModule(child).moduleFactory = document.moduleFactory;
+
+            else if (parent is IFlexModule && IFlexModule(parent).moduleFactory != null)
+                IFlexModule(child).moduleFactory = IFlexModule(parent).moduleFactory;
         }
 
         // Set the font context in non-UIComponent children.


    /**
     *  @private
     *  There is a bug (139381) where we occasionally get callLaterDispatcher()
     *  even though we didn't expect it.
     *  That causes us to do a removeEventListener() twice,

        var n:int = numChildren;
        for (var i:int = 0; i < n; i++)
        {
            var child:IFlexModule = getChildAt(i) as IFlexModule;
            if (!child)
                continue;

