Set new class selectors on different targets
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp()">
<mx:Script>
import mx.styles.StyleManager;
private var myButtonStyle:CSSStyleDeclaration = new CSSStyleDeclaration('myButtonStyle');
private var myLabelStyle:CSSStyleDeclaration = new CSSStyleDeclaration('myLabelStyle');
private var myTextAreaStyle:CSSStyleDeclaration = new CSSStyleDeclaration('myTextAreaStyle');
private function initApp():void {
myButtonStyle.setStyle('color', 'blue');
myLabelStyle.setStyle('color', 'blue');
myTextAreaStyle.setStyle('color', 'blue');
StyleManager.setStyleDeclaration("Button", myButtonStyle, false);
StyleManager.setStyleDeclaration("Label", myLabelStyle, false);
StyleManager.setStyleDeclaration("TextArea", myTextAreaStyle, true);
}
</mx:Script>
<mx:Button id="myButton" label="Click Me"/>
<mx:Label id="myLabel" text="This is a label" />
<mx:TextArea id="myTextArea" text="This is a TextArea" />
</mx:Application>
Related examples in the same category