- Character and paragraph styles for a text field are controlled by instances of the TextFormat class.
- To set the formatting of a character or span of characters:
- create a TextFormat object
- set its properties
- use TextField.setTextFormat() to apply the format to a text field's characters
// Create a text field.
this.createTextField("theField_txt", 1, 0, 0, 200, 20);
theField_txt.border = true;
theField_txt.text = "Press any key."
// Make the text format object.
format = new TextFormat();
// Set the text format object's properties.
format.bold = true;
format.size = 26;
// Apply the format to the whole field.
theField_txt.setTextFormat(format);
- This example add bullets to the beginning of each line in a text field.
this.createTextField("theField_txt", 1, 0, 0, 200, 60);
theField_txt.border = true;
theField_txt.text = "Item one.\nItem two.\nItem three."
// Make the text format object.
format = new TextFormat();
format.bullet = true;
// Make the whole field bulleted.
theField_txt.setTextFormat(format);
- Here are the character and paragraph styles that can be controlled via TextFormat properties:
align
Specifies horizontal paragraph alignment.
blockIndent
Specifies paragraph indentation.
bold
Boolean; specifies bold character display.
bullet
Specifies whether to add bullets to paragraphs.
color
Specifies character color.
font
Sets the font for specified characters.
indent
Specifies indentation for a paragraph's first line.
italic
Boolean; specifies italicized character display.
leading
Specifies line spacing.
leftMargin
Specifies width of the space to the left of a paragraph.
rightMargin
Specifies width of the space to the right of a paragraph.
size
Character font size, in points.
tabStops
Specifies horizontal tab stops, in points.
target
Specifies the window or frame for a hypertext link.
underline
Boolean; specifies underlined character display.
url
Specifies a hypertext link.