View Single Post
Old 06-10-2011, 09:54 PM   PM User | #3
PeatMoss
New to the CF scene

 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
PeatMoss is an unknown quantity at this point
I stumbled upon this as I had to iterate over the set of styles defined in some class descriptor defined in a CSS file. My solution comes from a perusal of the source code in CSSStyleDeclaration.getStyle() method. Here is a little helper function that returns all style declarations in a CSSStyleDeclaration as a Dictionary object:

Code:
private function getAllStyleDeclarations(css:CSSStyleDeclaration):Dictionary
      {
        var map:Dictionary = new Dictionary();
        var o:Object;
        var styleName:String;
        
        // See CSSStyleDeclaration.getStyle() for motivation...
        // Get defaults first
        if (css.defaultFactory != null)
        {
          o = new css.defaultFactory();
          for (styleName in o)
          {
            map[styleName] = o[styleName];
          }
        }
        
        if (css.factory != null)
        {
          o = new css.factory();
          for (styleName in o)
          {
            map[styleName] = o[styleName];
          }
        }
        
        if (css.overrides != null)
        {
          for (styleName in css.overrides)
          {
            map[styleName] = css.overrides[styleName];
          }
        }
        
        return(map);
      }
It worked for me in my environment, but I can't say that it will work for you. Your mileage may vary.
PeatMoss is offline   Reply With Quote