package
{
import flash.display.Sprite;
public class ArrayFind extends Sprite
{
private var myArray:Array = new Array("one", "two", "three", "five", "ten", "twenty", "two", "sixty");
public function ArrayFind()
{
// find the location of "five"
trace ( myArray.indexOf( "five" ) ); // outputs 3
// find the location of "two" from the beginning
trace ( myArray.indexOf( "two" ) ); // outputs 1
// find the location of "two" from the end
trace ( myArray.lastIndexOf( "two" ) ); // outputs 6
// check to see if element is in the array
trace ( myArray.indexOf( "five hundred" ) ); // outputs -1
}
}
}
Posted in Actionscript 3, Arrays.
By admin
– September 24, 2008
that is something useful I’ve never used…