is there a way to generate random hex colours using AS or do i need to define a set of hexs and then use a random var to determine which one is used?
r = Math.ceil(Math.random()*255);
r = (r<16) ? 0+r.toString(16) : r.toString(16);
g = Math.ceil(Math.random()*255);
g = (g<16) ? 0+g.toString(16) : g.toString(16);
b = Math.ceil(Math.random()*255);
b = (b<16) ? 0+b.toString(16) : b.toString(16);
trace("0x" + r + g + b);
you can also use:
random(0xFFFFFF);
or alternatively you could do it with non-depricated methods…
either…
Math.random() * 0xFFFFFF;
or…
Math.round( Math.random() * 0xFFFFFF );
Take Care.
_Michael
i don’t know what ‘non-depricated’ means but thanks. does it give any better performance?
Depricated functions are the old way of doing things, and eventually will be removed (in like four versions :P). The new way is more OOP…
Exactly, they are just methods that aren’t promised to be supported in future versions of the Flash Player.
_Michael