While working on a project at Schematic, I was investigating the possibility of defining style attributes for component instances in an external CSS file. I got the following system to work:
1. Create an external CSS file, defining the style(s) and component-specific styles you want to customize. For example:
/* Filename: styles.css */ checkbox { color: 0x0000FF; embedFonts: false; fontFamily: Arial; fontSize: 24; }
2. Load the style sheet into your Flash movie, retrieve the style name, and apply it to your instance:
import mx.controls.CheckBox; var oStyle:Object; var ccbTest:mx.controls.CheckBox; var styles = new TextField.StyleSheet(); styles.onLoad = function(bSuccess:Boolean):Void { if (bSucess) { oStyle = this.getStyle("checkbox"); for(var i in oStyle){ ccbTest.setStyle(i, oStyle[i]); } } else { trace("Error loading CSS file."); } }; styles.load("styles.css");
--From (http://blogs.flashsupport.com/robert/archive/2004/09/08/209.aspx) 
|