
TextFormat.font Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
893
TextFormat.color Property
specifies character color
Flash 6
read/write
theFormat.color
Description
The integer color property specifies the color of characters using RGB hexadecimal triplet
notation—
0xRRGGBB, where RR, GG, and BB are two-digit hex numbers representing Red,
Green, and Blue. For example, the following sets
color to red:
theFormat.color = 0xFF0000;
For a complete discussion of RGB triplet notation, see the Color class.
To set the color of an entire text field, invoke TextField.setTextFormat() without specifying
any index arguments:
this.createTextField("theField_txt", 1, 0, 0, 200, 20);
theField_txt.border = true;
theField_txt.text = "Play with color."
// Create a TextFormat object
format = new TextFormat();
format.color = 0xFF0000;
// Make the whole field red
theField_txt.setTextFormat(format);
Alternatively, use the convenient TextField.textColor property directly on the field,
without a TextFormat object:
theField_txt.textColor = 0xFF0000;
To set the color of a single character, apply the format with a single index argument:
theField_txt.setTextFormat(0, format); // Make the first character red
To set the color of a range of characters, apply the format with start and end index
arguments:
theField_txt.setTextFormat(10, 15, ...