Just a wee code snippet in case I need it again one day. Adding stylesheet functionality I’d usually use external CSS for from within the actionscript. Pretty easy:
static private function setStyleSheet():void { styleSheet = new StyleSheet(); // create object for each style //links var a:Object = { color: "#FF0000" } styleSheet.setStyle("a", a); var hover:Object = { color: "#FF9900" } styleSheet.setStyle("a:hover", hover); var active:Object = { color: "#000000" } styleSheet.setStyle("a:active", active); }
Then if I wanted to assign that stylesheet to a TextField, I’d go:
MyTextField.styleSheet = styleSheet;
Tech Reference: AS3
Leave a Reply