Flashhilfe.de - Flash Community

Prototype: Array_unique(); [Flash 8]

Forum > Tipps & Tricks zu Flash, Flex und Adobe AIR > Prototype: Array_unique();

 


AntwortenRegistrieren Seite1  

 25.06.2003, 01:02 
Benutzerbild von SebastianFlashhilfe.de Moderator
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
Schlagwörter: Array, prototype
 
Themen
Ähnliche Beiträge zum Thema
 

AntwortenRegistrieren Seite1  

Schnellantwort

Du musst registriert sein, um diese Funktion nutzen zu können.
Partner Webseiten: DesignerInAction.de   Designnation.de   Mediengestalter.info   php-resource.de   phpforum.de   phpwelt.de   Pixelio.de   PSD-Tutorials.de   Tutorials.de

Haftungsausschluss   Datenschutzerklärung   Hier Werben   Impressum
© 1999-2012 Sebastian Wichmann - Flashhilfe.de