Random Color hex display

I have a button that changes the RBG of an object like this:
[AS]
on(release) {
myColor = Math.round( Math.random()*0xFFFFFF );
myColoredObject = new Color (_root.square);
myColoredObject.setRGB(myColor);

}

[/AS]

how can i make it so it displays the hex number for the color in a dynamic text box?

Here is something I made a long while back, it may be of some help to you…

That’s perfect, thanks :slight_smile:

on(release) {
	myColor = Math.round( Math.random()*0xFFFFFF );
	myColoredObject = new Color (_root.square);
	myColoredObject.setRGB(myColor);
	
	myColor = myColor.toString(16); // convert hex value to a hex string
	while (myColor.length < 6) myColor = "0"+myColor; // make sure the hex string has 6 characters
	_root.myTextbox.text = "color = #"+myColor; // set it to the textfield text
}

… dont know what lost’s example was, but theres one for ya :slight_smile: the myColor.toString(16) is the important part there.

Yeah set… myColor.getRGB().toString(16) is the important part in my script.

My script was meant to be a random color generator that generated a random hex value and printed the RGB value too (for those programs that don’t have HEX ability and you need to know the seperate red green and blue values)

So it’s a little more than what was needed, but i’m tired, stressed, and on the verge of suicide, so I don’t have time to help much :frowning: