Archive for March 7th, 2008


The Good Ol’ indexOf

March 7, 2008

For those of you who might have come from programming in JavaScript, I’m sure indexOf is a pretty handy method when playing around with strings. Flex extends its usage to Arrays too. You can use indexOf in a similar way as you do with strings. In this case, it matches the exact string in all the substrings and returns the substring position in the array.


var arr:Array = new Array("apple","mango","orange","banana") ;

var num:uint = arr.indexOf("orange");

trace (num)  //returns 2