J'ai des tableaux imbriqués avec des paires de nombres:Vous ne trouvez pas un match
_open = [[8,15], [9,16]];
dont je veux trouver un match en utilisant ArrayUtilities.findMatchIndex mais il retourne toujours -1 lorsque la recherche d'un ensemble d'éléments . Par exemple:
ArrayUtilities.findMatchIndex(_open, [8, 15])
Je me demande s'il est possible pour AS3 de comparer les tableaux, parce que la comparaison d'autres types (chaînes, des nombres, etc.) fonctionnent très bien
Voilà findMatchIndex():
public static function findMatchIndex(aArray:Array, oElement:Object, ...rest):Number {
var nStartingIndex:Number = 0;
var bPartialMatch:Boolean = false;
if(typeof rest[0] == "number") {
nStartingIndex = rest[0];
}
else if(typeof rest[1] == "number") {
nStartingIndex = rest[1];
}
if(typeof rest[0] == "boolean") {
bPartialMatch = rest[0];
}
var bMatch:Boolean = false;
for(var i:Number = nStartingIndex; i < aArray.length; i++) {
if(bPartialMatch) {
bMatch = (aArray[i].indexOf(oElement) != -1);
}
else {
bMatch = (aArray[i] == oElement);
}
if(bMatch) {
return i;
}
}
return -1;
}