Edit: this solution does not work. All selectors that are output from the analyzer are converted to lowercase. This may work for your application, but it probably won't ...
I leave this answer here because it can help some people find a solution and warn others about the limitations of this method.
See my question: β Finding a CSS parser written in AS3 β for a full discussion, but I found a CSS parser hidden inside standard libraries. Here is how you can use it:
public function extractFromStyleSheet(css:String):void { // Create a StyleSheet Object var styleSheet:StyleSheet = new StyleSheet(); styleSheet.parseCSS(css); // Iterate through the selector objects var selectorNames:Array = styleSheet.styleNames; for(var i:int=0; i<selectorNames.length; i++){ // Do something with each selector trace("Selector: "+selelectorNames[i]; var properties:Object = styleSheet.getStyle(selectorNames[i]); for (var property:String in properties){ // Do something with each property in the selector trace("\t"+property+" -> "+properties[property]+"\n"); } } }
Then you can apply the styles using:
cssStyle = new CSSStyleDeclaration(); cssStyle.setStyle("color", "<valid color>); FlexGlobals.topLevelApplication.styleManager.setStyleDeclaration("Button", cssStyle, true);
sixtyfootersdude
source share