         var styleName:Object = obj.styleName;
         var styleDeclarations:Array;
         var decl:CSSStyleDeclaration;
-        var styleManager:IStyleManager2 = null;
-        
-        if (target is UIComponent)
-            styleManager = UIComponent(target).styleManager;
-    
-        if (!styleManager)
-            styleManager = StyleManager.getStyleManager(null);
+        var styleManager:IStyleManager2 = getStyleManager(target);
         
         // If we have an advanced style client, we handle this separately
         // because of the considerably more complex selector matches...

    public static function setStyle(object:IStyleClient, styleProp:String,
                                    newValue:*):void
    {
        var styleManager:IStyleManager2;
        
        if (object is UIComponent)
            styleManager = UIComponent(object).styleManager;
        else
            styleManager = StyleManager.getStyleManager(null);
        
        if (styleProp == "styleName")
        {


import mx.core.FlexGlobals;
import mx.core.IFlexDisplayObject;
import mx.core.IFlexModule;
import mx.core.IFlexModuleFactory;
import mx.core.IFontContextComponent;
import mx.core.IInvalidating;
