Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

setRandom.as

Name: setRandom() - converts color to random hex color and returns that value
Author: senocular: www.senocular.com
Date: 1899-12-31T00:17:01.900
Documentation:
Color SETRANDOM: changes the color to a random
color (RGB hex) and returns that color in hex value.
 
Returns:
- returns a number between 1 and 16777215 (which is 000000 - ffffff) representing
the color this color object was set to.


Example:
col = new Color(_root.clip);
randCol = col.setRandom(); // sets clip to random color
col.setRGB(0xFFFFFF); // sets clip to white
col.setRGB(randCol); // returns clip to old random color

1
2
3
4
5
Color.prototype.setRandom = function(){
	var ran = Math.floor(Math.random()*0xFFFFFF);
	this.setRGB(ran);
	return ran;
}