How do I create a custom colour scale ideally in Hex? say from yellow to red, depending on the height of an object? is this a correct way to achieve this or is there a better way without having to convert it at the end?:
var r:int = 255;
var b:int = 0;
var maxHeight:int = 52;
var minHeight:int = 21;
var scale:int = 255 / (maxHeight-minHeight);
var g:int = 255 - ((object.height-minHeight) * scale);
var hexColor:uint = RGBtoHEX(r,g,b);
private function RGBtoHEX(r:int, g:int, b:int) :uint
{
return r << 16 | g << 8 | b;
}
Here is a function that allows you to find a colour value between two others based on a range of 0-1. I think it will meet your needs