388
Working with Text and Strings
3.
To access the methods and properties of the newly created text field, use the instance name
specified in the first parameter of the
createTextField()
method.
For example, the following code creates a new text field named
test_txt
, and modifies its
properties to make it a multiline, word-wrapping text field that expands to fit inserted
text. Then it assigns some text using the text field’s
text
property:
test_txt.multiline = true;
test_txt.wordWrap = true;
test_txt.autoSize = "left";
test_txt.text = "Create new text fields with the
MovieClip.createTextField() method.";
4.
Select Control > Test Movie to see the text field.
The text is created at runtime and appears on the Stage.
You can use the
TextField.removeTextField()
method to remove a text field created with
createTextField()
. The
removeTextField()
method does not work on a text field placed
by the timeline during authoring.
For more information, see createTextField (MovieClip.createTextField method) and
removeTextField (TextField.removeTextField method) in the
ActionScript 2.0 Language
Reference.
You can find sample source files that demonstrate how to work with text fields using
ActionScript. The source files are called textfieldsA.fla and textfieldsB.fla, and you can find
them in the Samples folder on your hard disk:
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\TextFields.
■
On the Macintosh, browse to
Macintosh HD
/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/TextFields.
NO
TE
Some TextField properties, such as
_rotation
, are not available when you create text
fields at runtime. You can rotate a text field only if it uses embedded fonts. See
“To
embed a font symbol:” on page 400
.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...