The uiTextStyles manager contains text formatting information used by uiText components.
See Also: Text Styles
You do not normally need to access the uiTextStyles manager in your application code.
The uiTextStyles manager is initialized and used automatically by the Aspire UI framework. The manager automatically loads and parses a CSS file from the theme folder. This CSS file, which by default is “text.css”, contains all the text styles that your application may use. You may edit “text.css” to meet your requirements, or you may specify an alternative CSS file by changing an entry in “rules.xml”.
Defining Text Styles via ActionScript
As mentioned above, you would normally define text styles via CSS in the “text.css” file. If for whatever reasons you wish to define text styles programmatically via ActionScript, you may do so using the uiTextStyles.manager.setStyle() method1):
import com.ghostwire.ui.controls.uiText; import com.ghostwire.ui.managers.uiTextStyles; // ** define a "specialstyle" text style ** uiTextStyles.manager.setStyle("specialstyle",{color:"#FFFFFF",outline:"#333333"}); var txt:uiText = new uiText("Hello World!"); txt.textStyle = "specialstyle"; addChild(txt);
Overriding Text Styles via ActionScript
If you wish to override text styles that are already defined in the “text.css” CSS file, you must do so after the CSS file has been loaded and parsed.
Consider a “default” text style defined in CSS2):
default { fontFamily:Tahoma; fontSize:12; color:#000000; }
To override this style via ActionScript:
import com.ghostwire.ui.containers.uiBox; import com.ghostwire.ui.controls.uiLabelButton; import com.ghostwire.ui.managers.uiSkins; import com.ghostwire.ui.managers.uiTextStyles; uiSkins.manager.addEventListener(Event.INIT,main); function main(evt:Event) { // ** override the "default" text style ** uiTextStyles.manager.setStyle("default",{fontFamily:"Comic Sans MS",fontSize:11,fontWeight:"bold"}); var btn1:uiLabelButton = new uiLabelButton("Button 1"); var btn2:uiLabelButton = new uiLabelButton("Button 2"); var btn3:uiLabelButton = new uiLabelButton("Button 3"); var box:uiBox = new uiBox(); box.spacing = 5; box.addChild(btn1); box.addChild(btn2); box.addChild(btn3); addChild(box); }
NOTE: Although you are able to define text styles via the uiTextStyles.manager.setStyle() method, it is recommended that you keep all your desired text styles defined in the “text.css” CSS file, for flexibility as well as maintenance reasons.
For more information on the members of the com.ghostwire.ui.managers.uiTextStyles class, please refer to the API Reference.