flash as3 - how do I find an object's index in an array -
how find object's index / position within array in flash actionscript 3? trying set conditional in loop where, if object's id equal current_item variable, can return position within array.
something might - example returns position of value 7:
private var _testarray:array = new array(5, 6, 7, 8, 9, 8, 7, 6); public function arraytest() { trace (_testarray.indexof(7)); //should output 2 }
so needs:
item variabletolookfor = 9 // variable here private var _testarray:array = new array(5, 6, 7, 8, 9, 8, 7, 6); public function arraytest() { trace (_testarray.indexof(variabletolookfor)); //should output 4 }
this return -1 if item doesn't exist, otherwise output position in array.
if need more information can check here article on as3 arrays.
Comments
Post a Comment