User Guide

About styles 185
Setting styles using MXML tag attributes
Component users can use MXML tag attributes to set a style property on a component. For
example, the following code creates a TextArea control, then sets the
backgroundColor style
of the component to blue (0x0000FF):
<mx:TextArea id="myTA" backgroundColor="0x0000FF"/>
Setting styles using the setStyle() method
Component users can use the setStyle() method to set a style property on a component.
For example, the following code creates a Te xt A re a control, then sets the
backgroundColor
style of the component to blue (0x0000FF):
var myTA:TextArea=new TextArea()
myTA.setStyle('backgroundColor', 0x0000FF);
Setting styles using CSS
Component users can use the <mx:Styles> tag to set CSS styles in an MXML application, as
the following example shows:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<mx:Style>
TextArea {backgroundColor: "0x0000FF"}
</mx:Style>
<mx:TextArea/>
</mx:Application>
You can also import an external CSS file, as the following example shows:
<mx:Style source="myStyle.css"/>