Простой ответ: Vector.indexOf()
ищет по ссылке.В вашем коде вы создали два совершенно отдельных объекта;они могут выглядеть идентично вам, но это потому, что вы человек:)
const v : Vector.<Object> = new Vector.<Object>();
const geoff : Object = { name: "Geoffrey", age: 32 };
v.push(geoff);
const index : uint = v.indexOf(geoff);
trace("Geoff is at index: " + index); // Traces "Geoff is at index: 0".
Если вы хотите найти индекс объекта на основе его свойств, вы захотите использовать цикл fori
.
const people : Vector.<Object> = new Vector.<Object>();
people.push({ name: "Jonny", age: 28 });
people.push({ name: "Geoffrey", age: 32 });
const needle : String = "Geoffrey";
var index : int = -1;
for (var i : uint = 0; i < people.length; i++) {
if (people[i].name == needle) {
index = i;
break;
}
}
trace(needle + " found at index: " + index);