Random colours


I was looking for a way to apply random colours to a movie clip and came across a tutorial on this site called ‘Easy random Color’ (within ActionScript tricks) which works very well but I wondered if anybody knows of a way to limit the colour pallet (i.e. select from 10 colours)

code used:

myColor = Math.round( Math.random()*0xFFFFFF );
myColoredObject = new Color (_root.square);



i’m sure some guru in here could give you the exact code in 30 secs but it would take me an hour to work it out and test it … here’s what you would need to do though (there are probably other ways of doing this)

create an array whose values are to be applied to an MCinstance, within the array you would have the rgb values for each of the colors that you want it to choose between

then you would just make a script to pick math.random(9) … you’d pick (9) because its 0-9 which is equivelant to 10 choices.

anyway once it picks the number it takes that number as a variable and chooses the corresponding value from the array to apply to the MCinstance.

i think i made that sound too complicated … hope this helps