charAt (String.charAt method)

public charAt(index:Number) : String

Returns the character in the position specified by the parameter index. If index is not a number from 0 to string.length - 1, an empty string is returned.

This method is similar to String.charCodeAt() except that the returned value is a character, not a 16-bit integer character code.

Availability: ActionScript 1.0; Flash Player 5

Parameters

index:Number - An integer specifying the position of a character in the string. The first character is indicated by 0, and the last character is indicated by my_str.length-1.

Returns

String - The character at the specified index. Or an empty String if the specified index is outside the range of this String's indices.

Example

In the following example, this method is called on the first letter of the string "Chris":

var my_str:String = "Chris";
var firstChar_str:String = my_str.charAt(0);
trace(firstChar_str); // output: C

See also

charCodeAt (String.charCodeAt method)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00002158.html