Flashhilfe.de - Flash Community

Prototype: String.uniqid [Flash 8]

Forum > Tipps & Tricks zu Flash, Flex und Adobe AIR > Prototype: String.uniqid

 


AntwortenRegistrieren Seite1  

 09.07.2003, 19:54 
Benutzerbild von SebastianFlashhilfe.de Moderator
Beiträge: 6940
Wohnort: München
Registriert: Jan 2002

Prototype: String.uniqid
Erstellt eine eindeutige ID

Prototype:
ActionScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Array.prototype.find = function(eingabe) {
    return (this.toString().split(eingabe).length > 1);
}

String.uniqid = function(nr) {
   var str = "", b = "";
   for(var i=0;i<nr;i++) {   
      b = random(36).toString(36);
      str += random(2) ? b.toUpperCase() : b.toLowerCase();
   }
   if(temp_ary.find(str)) {
      String.uniqid(nr);   
   } else {
      temp_ary.push(str);   
   }
   return str;
}

// ##################################### //
// Einzelnt:

String.uniqid = function(nr) {
   var str = "", b = "";
   for(var i=0;i<nr;i++) {   
      b = random(36).toString(36);
      str += random(2) ? b.toUpperCase() : b.toLowerCase();
   }
   return str;
}


Beispiel Aufruf:
ActionScript:
1
2
3
4
5
6
7
// In dem Beispiel wird prototpye.find benutzt um 100 eindeutige IDs zu erzeugen.
// Die IDs werden dabei in einem Array: temp_ary gespeichert.

temp_ary = [];
for(i=0;i<100;i++) {
   String.uniqid(10);
}

Flex Freelancer || Flashhilfe @ Twitter || XING Profil
Schlagwörter: prototype, String
 
Themen
Ähnliche Beiträge zum Thema
number in string konvertieren [Flash 10] 14.02.2010 - marco_reinhold
 

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