| String.charAt( ) Method | Flash 5 |
| retrieve the character from a specific position in a string |
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).
The character in the position index within string.
The charAt( ) method determines the character that resides at a certain position (index) in a string.
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;
}
String.charCodeAt( ), String.indexOf( ), String.slice( ); "The charAt( ) function," in Chapter 4