Return to Snippet

Revision: 40902
at February 9, 2011 21:45 by adrianparr


Initial Code
var magentaRed:int = 255;
var magentaGreen:int = 0;
var magentaBlue:int = 255;
var magentaCSS:String = RGBToCSS(magentaRed, magentaGreen, magentaBlue);
trace("magentaCSS: " + magentaCSS);

function RGBToCSS(r:int, g:int, b:int):String
{
	var hex:uint = r << 16 | g << 8 | b;
	return "#" + hex.toString(16).toUpperCase();
}

// OUTPUT
// magentaCSS: #FF00FF

Initial URL

                                

Initial Description

                                

Initial Title
AS3 RGB Colour to CSS Colour (String)

Initial Tags
css, color

Initial Language
ActionScript 3