Formatting text with Cascading Style Sheet styles
427
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
property.
textObj_txt.styleSheet = styles;
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
text
and
htmlText
properties, and any variable associated with the text
field, always contain the same value and behave identically.
■
The text field becomes read-only and cannot be edited by the user.
■
The
setTextFormat()
and
replaceSel()
methods of the TextField class no longer
function with the text field. The only way to change the field is by altering the text field’s
text
or
htmlText
property or by changing the text field’s associated variable.
■
Any text assigned to the text field’s
text
property,
htmlText
property, or associated
variable is 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
property.
The following examples create a style sheet object,
styles
, and assign it to the
myTextArea
component instance.
Using a style sheet with a TextArea component:
1.
Create a new Flash document and save it as
textareastyle.fla
.
2.
Drag a TextArea component from the User Interface folder of the Components panel to
the Stage and give it an instance name of
myTextArea
.
NO
T
E
Do not confuse the
TextField.styleSheet
property
with the TextField.StyleSheet
class
.
The capitalization indicates the difference.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...