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.