我试图扩展 flex ArrayCollection 以便能够搜索包含特定数据的对象并将其返回。
这是我的功能:
public function getItemContaining(value: String): Object {
//Loop through the collection
for each(var i: Object in this) {
//Loop through fields
for(var j: String in i) {
//If field value is equal to input value
if(i[j] == value) {
return i;
}
}
}
//If not found
return null;
}
问题是 j 始终为空,因此第二个循环永远不会起作用。所以我阅读了 flex 循环描述,实际上它应该可以正常工作。可能是什么问题?