Retrieving One Character at a Time : charAt « String « Flash / Flex / ActionScript






Retrieving One Character at a Time

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:String = "a string";
        
        for ( var i:int = 0; i < example.length; i++ ) {
          trace( example.charAt( i ) );
        }
    }
  }
}

        








Related examples in the same category

1.charAt() takes one parameter, a value for an index within the string. This method returns a new one-character string that contains the value of the character at the specified index.
2.Use of a for loop to loop through the characters of a string, one at a time