flsg -> RE: Flash Q&A thread 3 (6/29/2007 21:29:54)
|
eragon: lol just what I thought a precision: use for(var i:Number=arrayName.lengh-1; i<=0; i--) instead of the normal i++ since it's faster OMG I really don't have anything else to say XD so I'll give you the code var part1:Array = ["flsg's ", "eragon's ", "artix's "];
var part2:Array = ["super ", "ultra ", "mega "];
var part3:Array = ["blabla1 ", "blabla2 ", "blabla3 ", "blabla4 "];//can't think of something
var part4:Array = ["dagger ", "blade ", "sword ", "axe ", "staff "];
var part5:Array = ["of bla1", "of bla2", "of bla3"];
var randomName:String = "";
var nameLength:Number = random(3)+3;
function getEssentialWord():String {
//the essential parts are part2, 3 and 4
var tempName:String = part2[random(part2.length)]+part3[random(part3.length)]+part4[random(part4.length)];
return tempName;
}
randomName=getEssentialWord()
nameLength>=4 ? randomName=part1[random(part1.length)]+randomName : randomName;
nameLength==5 ? randomName+=part5[random(part5.length)] : randomName;
trace(randomName); already tested, seems to work
|
|
|
|