Prototype: Array.unique [Flash 8]
| Beiträge: 130 Wohnort: Berlin/Germany Registriert: Mar 2002
| 28.06.2003, 18:42
Entfernt doppelte Einträge aus einem Array
Prototype:
ActionScript:1 2 3 4 5 6 7 8 9 | Array.prototype.unique = function() {
for (var i = 0; i < this.length; i++) {
for (var j = (i + 1); j <= this.length; j++) {
if (this[i] === this[j]) {
this.splice(j, 1);
}
}
}
};
|
Beispiel Aufruf:
ActionScript:1 2 3 4 | // Verwenden
liste = new Array(1,2,3,2,"1",8);
liste.unique();
trace(liste);
|
[Flashstar]
http://www.flashstar.de | | | Beiträge: 40 Wohnort: Rheinland Registriert: Jan 2004
| 04.02.2004, 12:47
Anstatt for (var j = (i + 1); j <= this.length; j++) kannst du for (var j = (i + 1); j < this.length; j++) { machen...
"...und dann tritt die realität ein!" | | | Beiträge: 130 Wohnort: Berlin/Germany Registriert: Mar 2002
Themenautor/in
| 04.02.2004, 20:28
Wie heisst es so schön mehrere Wege führen nach rom. Danke für einen weiteren. :)
[Flashstar]
http://www.flashstar.de[Flashstar]
http://www.flashstar.de | |
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News 
Regeln & Bedingungen
|