Skip to main content

RGB to Hexadecimal in ActionScript

(No Ratings Yet)

The following method simply converts a given RGB value to hexadecimal format..
i.e. 0 > #000000

public function getProperColor(input:int):String {
	var color:String = "#";
	var checker:Number = 0;
	if (input.toString(16).length<6) {
		while (checker<6-input.toString(16).length) {
			color += "0";
			checker++;
		}
	}
	color += input.toString(16);
	return color;
}

Leave a Reply

Your email address will not be published. Required fields are marked *