String

Object 
    | 
    +-String 
 
public class String 
extends Object

The String class is a wrapper for the string primitive data type, and provides methods and properties that let you manipulate primitive string value types. You can convert the value of any object into a string using the String() function.

All the methods of the String class, except for concat(), fromCharCode(), slice(), and substr(), are generic, which means the methods call toString() before performing their operations, and you can use these methods with other non-String objects.

Because all string indexes are zero-based, the index of the last character for any string x is x.length - 1.

You can call any of the methods of the String class using the constructor method new String or 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 then discards the temporary String object. You can also use the String.length property with a string literal.

Do not confuse a string literal with a String object. In the following example, the first line of code creates the string literal first_string, and the second line of code creates the String object second_string:

var first_string:String = "foo"  
var second_string:String = new String("foo") 

Use string literals unless you specifically need to use a String object.

Availability

Flash Lite 2.0

Property summary

Modifiers

Property

Description

 

length:Number

An integer specifying the number of characters in the specified String object.

Properties inherited from class Object

Constructor summary

Signature

Description

String(value:String)

Creates a new String object.

Method summary

Modifiers

Signature

Description

 

charAt(index:Number) : String

Returns the character in the position specified by the parameter index.

 

charCodeAt(index:Number) : Number

Returns a 16-bit integer from 0 to 65535 that represents the character specified by index.

 

concat(value:Object) : String

Combines the value of the String object with the parameters and returns the newly formed string; the original value, my_str, is unchanged.

static

fromCharCode() : String

Returns a string comprising the characters represented by the Unicode values in the parameters.

 

indexOf(value:String, [startIndex:Number]) : Number

Searches the string and returns the position of the first occurrence of value found at or after startIndex within the calling string.

 

lastIndexOf(value:String, [startIndex:Number]) : Number

Searches the string from right to left and returns the index of the last occurrence of value found before startIndex within the calling string.

 

slice(start:Number, end:Number) : String

Returns a string that includes the start character and all characters up to, but not including, the end character.

 

split(delimiter:String, [limit:Number]) : Array

Splits a String object into substrings by breaking it wherever the specified delimiter parameter occurs and returns the substrings in an array.

 

substr(start:Number, length:Number) : String

Returns the characters in a string from the index specified in the start parameter through the number of characters specified in the length parameter.

 

substring(start:Number, end:Number) : String

Returns a string comprising the characters between the points specified by the start and end parameters.

 

toLowerCase() : String

Returns a copy of the String object, with all uppercase characters converted to lowercase.

 

toString() : String

Returns an object's properties as strings regardless of whether the properties are strings.

 

toUpperCase() : String

Returns a copy of the String object, with all lowercase characters converted to uppercase.

 

valueOf() : String

Returns the string.

Methods inherited from class Object