      */
     public static function getClassStyleDeclarations(object:IStyleClient):Array
     {
-        var myApplicationDomain:ApplicationDomain;
-
-        var factory:IFlexModuleFactory = ModuleManager.getAssociatedFactory(object);
-        if (factory != null)
-        {
-            myApplicationDomain = ApplicationDomain(factory.info()["currentDomain"]);
+        var className:String = object.className;
+        var advancedObject:IAdvancedStyleClient = object as IAdvancedStyleClient;
+
+        var typeHierarchy:OrderedObject = getUnqualifiedTypeHierarchy(object);
+        var types:Array = typeHierarchy.propertyList;
+        var typeCount:int = types.length;
+        var classDecls:Array = null;
+
+        if (!StyleManager.hasAdvancedSelectors())
+        {
+            classDecls = StyleManager.typeSelectorCache[className];
+            if (classDecls)
+                return classDecls;
+        }
+
+        classDecls = [];
+
+        // Loop over the type hierarhcy starting at the base type and work
+        // down the chain of subclasses.
+        for (var i:int = typeCount - 1; i >= 0; i--)
+        {
+            var type:String = types[i].toString();
+            if (StyleManager.hasAdvancedSelectors() && advancedObject != null)
+            {
+                var decls:Object = StyleManager.getStyleDeclarations(type);
+                if (decls)
+                {
+                    var matchingDecls:Array = getMatchingStyleDeclarations(decls, advancedObject);
+                    classDecls = classDecls.concat(matchingDecls);
+                }
+            }
+            else
+            {
+                var decl:CSSStyleDeclaration = StyleManager.getStyleDeclaration(type);
+                if (decl)
+                    classDecls.push(decl);
+            }
+        }
+
+        if (StyleManager.hasAdvancedSelectors() && advancedObject != null)
+        {        
+            // Advanced selectors may mean more than one match per type so we
+            // sort based on specificity, but preserving the declaration
+            // order for equal selectors.
+            classDecls = sortOnSpecificity(classDecls);
         }
         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;
+            // Cache the simple type declarations for this class 
+            StyleManager.typeSelectorCache[className] = classDecls;
+        }
+
+        return classDecls;
     }
 
     /**

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

        // Then sort by specificity...
        matchingDecls = sortOnSpecificity(matchingDecls);

        return matchingDecls;
    }

    /**
     *  @private
     *  TODO: Replace this key generation as this is reasonably expensive in
     *  terms of string creation.
     */ 
    private static function getAdvancedCacheKey(className:String, object:IAdvancedStyleClient):String
    {
        var cacheKey:String = className;

        if (object.id)
            cacheKey += object.id;

        if (object.styleName)
            cacheKey += object.styleName;

        if (object.currentState)
            cacheKey += object.currentState;

        if (object.styleParent)
            cacheKey += getAdvancedCacheKey(object.styleParent.className, object.styleParent);

        return cacheKey;
    }

    /**


import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.utils.describeType;

import mx.core.ApplicationGlobals;
import mx.core.FlexVersion;
