I've an array with some properties. When I try to find an object's index I'm getting error TypeError: Error #1009. I'm using Flash CS6.
Here's my array:
Code:
var squareArr:Object = {
a1: {
piece: wr1_txt,
pieceLoc: {
x: "-3",
y: "347"
}
},
b1: {
piece: wn1_txt,
pieceLoc: {
x: "47",
y: "347"
}
},
...
Below code is giving me error #1009 while I want it to return a1:
Code:
trace (squareArr.indexOf(wr1_txt));
I tried:
Code:
var s:String;
var found:Boolean=false;
for (s in squareArr) {
if (squareArr[s].piece == wr1_txt) { // YAY found it
found=true;
break;
}
}
if (found) trace(s); else trace("Not found!");
but it says not found