      */
     private static function getTypeHierarchy(object:IStyleClient, qualified:Boolean=true):OrderedObject
     {
-        var styleManager:IStyleManager2;
-        
-        if (object is UIComponent)
-            styleManager = UIComponent(object).styleManager;
-        else
-            styleManager = StyleManager.getStyleManager(null);
-        
+        var styleManager:IStyleManager2 = getStyleManager(object);
         var className:String = getQualifiedClassName(object);
         var hierarchy:OrderedObject = styleManager.typeHierarchyCache[className] as OrderedObject;
         if (hierarchy == null)

     */
    public static function matchesCSSType(object:IAdvancedStyleClient, cssType:String):Boolean
    {
        var styleManager:IStyleManager2;
        
        if (object is UIComponent)
            styleManager = UIComponent(object).styleManager;
        else
            styleManager = StyleManager.getStyleManager(null);
        
        var qualified:Boolean = styleManager.qualifiedTypeSelectors;
        var typeHierarchy:OrderedObject = getTypeHierarchy(object, qualified);
        return typeHierarchy.object_proxy::getObjectProperty(cssType) != null;


        return decls; 
    }
    
    /**
     *  @private
     *  Get the style manager of any object. If the object does not implement IFlexModule or
     *  is not of type StyleProxy, then the top-level style manager will be returned.
     * 
     *  @param object - Typed as Object because various interfaces are passed here.
     *  @return a style manager, will not be null.
     */ 
    private static function getStyleManager(object:Object):IStyleManager2
    {
        if (object is IFlexModule)
            return StyleManager.getStyleManager(IFlexModule(object).moduleFactory);
        else if (object is StyleProxy)
            return getStyleManagerFromStyleProxy(StyleProxy(object));
        else
            return StyleManager.getStyleManager(null);
    }

    /**
     *  @private
     *  Get the style manager for a given StyleProxy object.
     * 
     *  @return a style manager, will not be null.
     */ 
    private static function getStyleManagerFromStyleProxy(obj:StyleProxy):IStyleManager2
    {
        // StyleProxy's usually have sources that are DisplayObject's, but a StyleProxy can also have 
        // another StyleProxy as it's source (Example: CalendarLayout's source is a StyleProxy for DateChooser, 
        // whose style is a StyleProxy for DateField)
        var curObj:IStyleClient = obj;
        while (curObj is StyleProxy)
        {
            curObj = StyleProxy(curObj).source;
        }

        if (curObj is IFlexModule)
            return StyleManager.getStyleManager(IFlexModule(curObj).moduleFactory);
        
        return StyleManager.getStyleManager(null);
    }
}

}
