 
 import mx.core.IFontContextComponent;
 import mx.core.IInvalidating;
-import mx.core.IFlexModuleFactory;
 import mx.core.IUITextField;
 import mx.core.mx_internal;
 import mx.core.UIComponent;

     */
    public static function getClassStyleDeclarations(object:IStyleClient):Array
    {
        var myApplicationDomain:ApplicationDomain;

        var factory:IFlexModuleFactory = ModuleManager.getAssociatedFactory(object);
        if (factory != null)
        {
            myApplicationDomain = ApplicationDomain(factory.info()["currentDomain"]);
        }
        else
        {
            var myRoot:DisplayObject = SystemManager.getSWFRoot(object);
            if (!myRoot)
                return [];
            myApplicationDomain = myRoot.loaderInfo.applicationDomain;
        }

        var className:String = getQualifiedClassName(object)
        className = className.replace("::", ".");

        var advancedObject:IAdvancedStyleClient = object as IAdvancedStyleClient;

        var cacheKey:String = advancedObject ? getAdvancedCacheKey(className, advancedObject) : className;
        var cache:Array = StyleManager.typeSelectorCache[cacheKey];
        if (cache)
           return cache;

        var decls:Array = [];
        var cacheKeys:Array = [];
        var caches:Array = [];
        var declcache:Array = [];

        while (className != null &&
               className != "mx.core.UIComponent" &&
               className != "mx.core.UITextField" &&
               className != "mx.graphics.graphicsClasses.GraphicElement")
        {
            cache = StyleManager.typeSelectorCache[cacheKey];
            if (cache)
            {
                decls = decls.concat(cache);
                break;
            }

            var ds:Array = null;
            if (advancedObject)
            {
                var d:Object = StyleManager.getStyleDeclarations(className);
                if (d)
                    ds = getMatchingStyleDeclarations(d, advancedObject, true);
            }
            else
            {
                var s:CSSStyleDeclaration = StyleManager.getStyleDeclaration(className);
                if (s)
                    ds = [s];
            }

            if (ds && ds.length > 0)
            {
                decls = ds.concat(decls);
                // We found one so the next set define the selectors
                // for this found class and its ancestors.
                // Save the old list and start a new list.
                cacheKeys.push(cacheKey);
                caches.push(cacheKeys);
                declcache.push(decls);
                decls = [];
                cacheKeys = [];
            }
            else
            {
                cacheKeys.push(cacheKey);
            }

            try
            {
                className = getQualifiedSuperclassName(
                    myApplicationDomain.getDefinition(className));
                className = className.replace("::", ".");

                cacheKey = advancedObject ? getAdvancedCacheKey(className, advancedObject) : className;
            }
            catch(e:ReferenceError)
            {
                className = null;
            }
        }

        caches.push(cacheKeys);
        declcache.push(decls);
        decls = [];

        while (caches.length)
        {
            cacheKeys = caches.pop();
            decls = decls.concat(declcache.pop());
            while (cacheKeys.length)
            {
                StyleManager.typeSelectorCache[cacheKeys.pop()] = decls;
            }
        }

        return decls;
    }

    /**

        for (var selector:String in declarations)
        {
            var decl:CSSStyleDeclaration = declarations[selector];
            if (decl.isMatch(object))
                matchingDecls.push(decl);
        }

        return matchingDecls;
    }

    /**
     *  @private 
     *  This should only be called once per type so avoiding a dependency on
     *  DescribeTypeCache and using describeType() directly.
     */
    private static function getUnqualifiedTypeHierarchy(object:IStyleClient):OrderedObject
    {
        var className:String = object.className;
        var hierarchy:OrderedObject = StyleManager.typeHierarchyCache[className];
        if (!hierarchy)
        {
            hierarchy = new OrderedObject();
            hierarchy[className] = true;

            var typeDescription:XML = describeType(object);
            var superClasses:XMLList = typeDescription..extendsClass;
            for each (var superClass:XML in superClasses)
            {
                var type:String = superClass.@type.toString();
                if (isStopClass(type))
                    break;
    
                type = NameUtil.getUnqualifiedClassName(type);
                hierarchy[type] = true;
            }
            StyleManager.typeHierarchyCache[className] = hierarchy;
        }

        return hierarchy;
    }

    /**
     *  @private
     *  Our style type hierarhcy stops at UIComponent, UITextField or
     *  GraphicElement, not Object.
     */  
    private static function isStopClass(value:String):Boolean
    {
        return value == null ||
               value == "mx.core::UIComponent" ||
               value == "mx.core::UITextField" ||
               value == "mx.graphics.graphicsClasses::GraphicElement";
    }

    /**
