Name

String( ) Global Function — convert a value to the String datatype

Availability

Flash 5

Synopsis

String(value)

Arguments

value

An expression containing the value to be converted to a string.

Returns

The result of converting value to a primitive string.

Description

The String( ) function converts its argument to a primitive string value and returns that converted value. The results of converting various types of data to a primitive string are described in Table 3.2. It’s normally not necessary to use the String( ) function; ActionScript automatically converts values to the string type when appropriate.

Be sure not to confuse the global String( ) function with the String class constructor. The former converts an expression to a string, whereas the later is a class that wraps primitive string data in an object so that properties and methods may be applied to it.

Usage

Note that the String( ) function sometimes appears in Flash 4 .fla files that have been converted to the Flash 5 format. For information on how datatypes are handled when Flash 4 files are converted to Flash 5, see Section 3.4.4 in Chapter 3.

See Also

The String class; Section 3.4.2 in Chapter 3

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.