Use of a for loop to loop through the characters of a string, one at a time : charAt « String « Flash / Flex / ActionScript






Use of a for loop to loop through the characters of a string, one at a time

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var sTitle:String = new String("ActionScript");
        for (var i:Number = 0; i < sTitle.length; i++){
           trace(sTitle.charAt(i));
        }
    }
  }
}
A
c
t
i
o
n
S
c
r
i
p
t

        








Related examples in the same category

1.Retrieving One Character at a Time
2.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.