Posted By

burnandbass on 12/17/11


Tagged


Versions (?)

Random generated String


 / Published in: ActionScript 3
 

This is easy way to generate random string

this will generate random word with 10 letters in it var a:String = randString(10);

  1. public function randString(_length:Number = 10):String{
  2. var alphabet:String = "qwertyuiopasdfghjklzxcvbnm123456789QWERTYUIOPASDFGHJKLZXCVBNM";
  3. var temp:Array = alphabet.split("");
  4. var tempString:String = "";
  5.  
  6. for(var i:Number = 0; i<_length; i++){
  7. tempString+= temp[ Math.ceil( Math.random()*alphabet.length - 1 )]
  8. }
  9.  
  10. return tempString;
  11. }

Report this snippet  

You need to login to post a comment.