450
Working with Text and Strings
To use the scroll property to create scrolling text:
1.
Do one of the following:
■
Use the Text tool to drag a text field on the Stage. Assign the text field the instance
name
textField_txt
in the Property inspector.
■
Use ActionScript to create a text field dynamically with the
MovieClip.createTextField()
method. Assign the text field the instance name
textField_txt
as a parameter of the method.
2.
Create an Up button and a Down button, or select Window > Common Libraries >
Buttons, and drag buttons to the Stage.
You will use these buttons to scroll the text up and down.
3.
Select the Down button on the Stage and type
down_btn
into the Instance Name text box.
4.
Select the Up button on the Stage and type
up_btn
into the Instance Name text box.
5.
Select Frame 1 on the Timeline, and, in the Actions panel (Window > Actions), enter the
following code to scroll the text down in the text field:
down_btn.onPress = function() {
textField_txt.= 1;
};
6.
Following the ActionScript in step 5, enter the following code to scroll the text up:
up_btn.onPress = function() {
textField_txt.scroll -= 1;
};
Any text that loads into the
textField_txt
text field can be scrolled using the up and
down buttons.
About strings and the String class
In programming, a string is an ordered series of characters. You use strings often in your Flash
documents and class files to display text in applications, such as within text fields. Also, you
can store values as strings that you can use in an application for a variety of purposes. You can
put strings directly in your ActionScript code by placing quotation marks around the
characters of data. For more information on creating strings, see
“Creating strings”
on page 458
. For information on using text fields, see
“Using the TextField class”
on page 384
.
NO
T
E
If you are
not
dynamically loading text into the SWF file, select Text > Scrollable
from the main menu.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...