Actionscript:
-
function randomChoice(...args:Array):*{
-
return args[int(Math.random()*args.length)];
-
}
-
-
// choose randomly from a number of different values
-
var val:* = randomChoice(10, "Hello", "0xFF0000", 1000);
-
-
// choose a random color (in this case red, green or blue)
-
var randColor:uint = randomChoice(0xFF0000, 0x00FF00, 0x0000FF);
-
-
trace(val);
-
trace(randColor);
The function randomChoice() takes any number of arguments and spits one of them back randomly. Just a handy function to have around... I especially like to use this function to choose from a handful of colors.