Controlling Text With Actionscript - MACROMEDIA FLASH MX 2004-USING FLASH Use Manual

Hide thumbs Also See for FLASH MX 2004-USING FLASH:
Table of Contents

Advertisement

Controlling text with ActionScript

A dynamic or input text field is an instance of the ActionScript TextField object. When you create
a text field, you can assign it an instance name in the Property inspector. You can use the instance
name in ActionScript statements to set, change, and format the text field and its content using the
TextField andTextFormat objects.
The TextField object has the same properties as the MovieClip object, and has methods that let
you set, select, and manipulate the text. The TextFormat object lets you set character and
paragraph values for the text. You can use these ActionScript objects instead of the text Property
inspector to control the settings of a text field.
You can use a text field's variable name or instance name to assign it text that contains HTML
tags. Flash preserves the rich text formatting applied to the text field with ActionScript.
If you assign a variable to a text field, the text field displays the variable's value. You can use
ActionScript to pass the variable to other parts of the Flash application, to a server-side
application for storing in a database, and so on. You can also replace the value of the variable by
reading it from a server-side application or by loading it from another part of the Flash
application. For more information on using variables, see "About variables" in Using ActionScript
Flash. For more information about connecting to external applications, see Chapter 11, "Working
with External Data,"in Using ActionScript Flash.
Creating and removing text fields dynamically
You can use the
field as a child of the movie clip that calls the method. You can use the
to remove a text field created with
created manually on the Timeline.
When you create a text field, you can use the TextField object to set properties of the text field. If
you don't set the properties, the new text field receives a set of default properties. The default
properties of the new text field are as follows:
type = "dynamic"
border = false
background = false
password = false
multiline = false
html = false
embedFonts = false
variable = null
maxChars = null
After you create a text field, you can use the TextFormat object to format the text. You must create
a new TextFormat object and then pass it as a parameter to the
TextField object. A text field created with the
default TextFormat object:
font = "Times New Roman"
size = 12
color = 0x000000
bold = false
124
Chapter 6: Working with Text
method of the MovieClip object to create a new, empty text
createTextField
createTextField
; this method will not work on a text field
setTextFormat
method receives the following
createTextField
method
removeTextField
method of the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents