Prototype: Array.lastIndexOf() Gibt den letzten vorkommenden Index aus einem Array zurück.
Prototype:
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 | Array.prototype.lastIndexOf = function (s) {
var index = -1;
for (var i in this) {
if (this[i] == s) {
index = i;
break;
}
}
index = (isNaN(index)) ? index : Number(index);
return index;
}
ASSetPropFlags(Array.prototype, "lastIndexOf", 7);
|
Beispiel Aufruf:
ActionScript:1 2 3 4 5 6 7 8 9 | num_array = [1,2,3,1];
str_array = new Array ();
str_array["a"] = 1;
str_array["b"] = 2;
str_array["c"] = 3;
str_array["d"] = 1;
trace (num_array.lastIndexOf(1) add " = " add typeof(num_array.lastIndexOf(1)));
trace (str_array.lastIndexOf(1) add " = " add typeof(str_array.lastIndexOf(1)));
|
MfG
Kai Jansen
Flashhilfe-Moderator
http://www.flashhilfe.de
http://www.kaijansen.de
Die Zukunft ist die Vergangenheit von Übermorgen. |