String.charAt( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
String.charAt( ) Method Flash 5

retrieve the character from a specific position in a string
string.charAt(index)

Arguments

index

The integer position of the character to retrieve, which should be in the range of 0 (the first character) to string.length - 1 (the last character).

Returns

The character in the position index within string.

Description

The charAt( ) method determines the character that resides at a certain position (index) in a string.

Example

trace("It is 10:34 pm".charAt(1));  // Displays: "t" (the second letter) var country = "Canada"; trace(country.charAt(0));           // Displays: "C" (the first letter)     // This function removes all the spaces from a string and returns the result function stripSpaces (inString) {   var outString = "";   for (i = 0; i < inString.length; i++) {     if (inString.charAt(i) != " ") {       outString += inString.charAt(i);     }   }   return outString; }

See Also

String.charCodeAt( ), String.indexOf( ), String.slice( ); "The charAt( ) function," in Chapter 4



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net