/ 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);
this will generate random word with 10 letters in it
var a:String = randString(10);
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public function randString(_length:Number = 10):String{ var alphabet:String = "qwertyuiopasdfghjklzxcvbnm123456789QWERTYUIOPASDFGHJKLZXCVBNM"; var temp:Array = alphabet.split(""); var tempString:String = ""; for(var i:Number = 0; i<_length; i++){ tempString+= temp[ Math.ceil( Math.random()*alphabet.length - 1 )] } return tempString; }