User Guide

TextArea.styleSheet 1203
The style sheet associated with a TextArea component may be changed at any time. If the style
sheet in use is changed, the TextArea component is redrawn with the new style sheet. The
style sheet may be set to
null or undefined to remove the style sheet. If the style sheet in use
is removed, the TextArea component is redrawn without a style sheet. The formatting done by
a style sheet is not retained if the style sheet is removed.
Example
The following code creates a new StyleSheet object named my_styles with the new
TextField.StyleSheet
constructor. It then defines styles for html and body tags. Next, it
applies the style by assigning
my_styles to the styleSheet property of the TextArea instance
my_ta.
You must first add an instance of the TextArea component to the Stage and name it
my_ta;
then add the following code to Frame 1.
/**
Requires:
- TextArea instance on Stage (instance name: my_ta)
*/
var my_ta:mx.controls.TextArea;
my_ta.setSize(320, 240);
// Create the new StyleSheet object.
var my_styles:TextField.StyleSheet = new TextField.StyleSheet();
my_styles.setStyle("html", {fontFamily:"Arial,Helvetica,sans-serif",
fontSize:"12px", color:"#0000FF"});
my_styles.setStyle("body", {color:"#00CCFF", textDecoration:"underline"});
// Set the TextAreaInstance.styleSheet property to the newly defined
// styleSheet object named styles.
my_ta.styleSheet = my_styles;
my_ta.html = true;
// Load text to display and define onLoad handler.
var my_lv:LoadVars = new LoadVars();
my_lv.onData = function(src:String) {
if (src != undefined) {
my_ta.text = src;
} else {
my_ta.text = "Error loading HTML document.";
}
};
my_lv.load("http://www.helpexamples.com/flash/lorem.txt");