Search code examples
actionscript-3flashflash-cs6

Get each element from array as string actionscript3


I have an array like var test:Array = new Array("a", "b", "c"); How can I write a method to get one element and make it be string each time when I call this method. i.e when I call the method, it should return only 'a' and next time return only 'b' and so on.


Solution

  • You can use function shift of Array,here is a link about the function array shift

    var test:Array = new Array("a", "b", "c"); 
    var firstLetter:String = test.shift();//"a"
    var secondLetter:String = test.shift();//"b"
    var thirdLetter:String = test.shift();//"c"