Prototype: Array_unique(); [Flash 8]
| 25.06.2003, 01:02 | | Beiträge: 6940 Wohnort: München Registriert: Jan 2002
| Prototype: Array_unique(); Entfernt doppelte Werte aus einem Array
Prototype:
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // FH Array_unique
//
// Copyright (C) 2003 Sebastian Wichmann :: sebastian at flashhilfe.de
// This Software is distributed under the GNU General Public License.
//
// http://www.flashhilfe.de
Array.prototype.array_unique = function() {
var i, j, checker, temp_ary = [], g = 0, laenge = this.length;
for(i=0;i<laenge;i++) {
checker = false;
for(j=0;j<temp_ary.length;j++)
if(temp_ary[j] === this[i])
checker = true;
if(checker == false)
temp_ary[g++] = this[i];
}
return temp_ary;
}
ASSetPropFlags(Array.prototype,"array_unique",1,true);
|
Beispiel Aufruf:
ActionScript:1 2 3 4 5 6 7 | test_array = [1,2,2,3,4,"4",4];
neues_array = test_array.array_unique();
trace(neues_array);
// Ausgabe:
// 1,2,3,4,4 <- eine 4 ist String, die andere Integer
|
Flex Freelancer || Flashhilfe @ Twitter || XING Profil | |
| | Themen Ähnliche Beiträge zum Thema | 16.06.2010 - skoda 29.09.2009 - regsnerven 28.10.2009 - usperry 14.03.2011 - skoda |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News 
Regeln & Bedingungen
|