Applying styles to a TextField object
To apply a style sheet object to a TextField object, you assign the style sheet object to the text
field's
styleSheet
textObj_txt.styleSheet = styleSheetObj;
Note: Do not confuse the
capitalization indicates the difference.
When you assign a style sheet object to a TextField object, the following changes occur to the text
field's normal behavior:
•
The text field's
always contain the same value and behave identically.
•
The text field becomes read-only and cannot be edited by the user.
•
The
setTextFormat()
with the text field. The only way to change the field is by altering the text field's
properties or by changing the text field's associated variable.
htmlText
•
Any text assigned to the text field's
stored verbatim; anything written to one of these properties can be retrieved in the text's
original form.
Applying a style sheet to a TextArea component
To apply a style sheet to a TextArea component, you create a style sheet object and assign it
HTML styles using the TextField.StyleSheet class. You then assign the style sheet to the TextArea
component's
styleSheet
The following examples create a style sheet object,
component instance:
//Creates a new style sheet object and sets styles for it
var styles = new TextField.StyleSheet();
styles.setStyle("html",
{fontFamily: 'Arial,Helvetica,sans-serif',
fontSize: '12px',
color: '#0000FF'}
);
styles.setStyle("body",
{color: '#00CCFF',
textDecoration: 'underline'}
);
styles.setStyle("td",
{fontFamily: 'Arial,Helvetica,sans-serif',
fontSize: '24px',
color: '#006600'}
);
//Assign the style sheet object to myTextArea component
//Set html property to true, set styleSheet property to the style sheet object
myTextArea.styleSheet = styles;
230
Chapter 9: Working with Text
property.
TextField.styleSheet
and
properties, and any variable associated with the text field,
text
htmlText
and
replaceSel()
text
property.
property with the TextField.StyleSheet class. The
methods of the TextField class no longer function
property,
property, or associated variable is
htmlText
, and assigns it to the
styles
or
text
myTextArea
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?
Questions and answers