The String class is a wrapper for the String primitive data type, and provides methods and
properties that let you manipulate primitive string values. You can convert the value of any
object into a string by using the
except for
,
concat()
the methods call the
use these methods with other non-String objects.
Because all string indexes are zero-based, the index of the last character for any
.
myStr.length - 1
You can find a sample source file, strings.fla, in the Samples folder on your hard disk. This file
shows you how to build a simple word processor that compares and retrieves string and
substring selections.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Strings.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Strings.
Creating strings
You can call any of the methods of the String class by using the
method or by using a string literal value. If you specify a string literal, the ActionScript
interpreter automatically converts it to a temporary String object, calls the method, and
discards the temporary String object. You can also use the
string literal.
Do not confuse a string literal with a String object. For more information on string literals and
the String object, see
In the following example, the line of code creates the
string literal, use single straight quotation mark (
delimiters.
458
Working with Text and Strings
String()
,
fromCharCode()
slice()
function before they perform their operations, and you can
toString()
Chapter 5, "About literals," on page
function. All the methods of the String class,
, and
substr()
new String()
String.length
130.
firstStr
) or double straight quotation mark (
'
, are generic, which means
string is
myStr
constructor
property with a
string literal. To declare a
)
"
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?