Using The Textformat Class - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Using the TextFormat class

You can use the ActionScript TextFormat class to set formatting properties of a text field. The
TextFormat class incorporates character and paragraph formatting information. Character
formatting information describes the appearance of individual characters: font name, point size,
color, and an associated URL. Paragraph formatting information describes the appearance of a
paragraph: left margin, right margin, indentation of the first line, and left, right, or
center alignment.
To use the TextFormat class, you first create a TextFormat object and set its character and
paragraph formatting styles. You then apply the TextFormat object to a text field using the
TextField.setTextFormat()
The
setTextFormat()
to groups of characters, or to the entire body of text in a text field. Newly inserted text,
however—such as text entered by a user or inserted with ActionScript—does not assume the
formatting specified by a
inserted text, use
TextField.setTextFormat()
Language Reference.
To format a text field with the TextFormat class:
In a new Macromedia Flash document, create a text field on the Stage using the Text tool. Type
1.
some text in the text field on the Stage, such as
In the Property inspector, type
2.
from the Text Type pop-up menu, and select Multiline from the Line Type pop-up menu.
In the Timeline, select the first frame in Layer 1, and open the Actions panel (Window >
3.
Development Panels > Actions).
Enter the following code in the Actions panel to create a TextFormat object, set the
4.
properties to
italic
// Create a TextFormat object
var txtfmt:TextFormat = new TextFormat();
// Specify paragraph and character formatting
txtfmt.bold = true;
txtfmt.italic = true;
txtfmt.size = 24;
224
Chapter 9: Working with Text
or
TextField.setNewTextFormat()
method changes the text format that is applied to individual characters,
setTextFormat()
TextField.setNewTextFormat()
and
TextField.setNewTextFormat()
myText_txt
, and the
true
size
call. To specify the default formatting for newly
. For more information, see
"Bold, italic, 24 point text"
in the Instance Name text box, select Dynamic
property to 24:
methods.
in Flash ActionScript
.
bold
and

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents