Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random color 2

Status
Not open for further replies.

intro66

MIS
May 27, 2003
5
IN
what would be the syntax for setting color to random?

i currently have it set to ONE color

myColor = new Color (_root.text1);
myColor.setRGB(0xFFFFFF);
 
This will change the colour of a clip to random values between #000000 and #ffffff every second (converted to base 10 rather than hex so it's easier to generate the random number), all you need is a clip on the stage with instance name 'myClip'...

function doRandomColour(clip) {
myColor = new Color(clip);
var colourCode = Math.round(Math.random()*16777216);
myColor.setRGB(colourCode);
}
//
setInterval(doRandomColour, 1000, myClip);
//
stop();
 
or for one change...timeline code

new Color(myclip).setRGB(random(1<<24));


or like wangbars for many changes...code on clip

onClipEvent (enterFrame) {
(new Color(this)).setRGB(random(1<<24));
}
 
thks guys. both worked great. used billwatsons becuase I just want it to change everytime the movie goes to that frame.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top