Yeah, that was slow as molasses my first code so I did what you suggested...
- Unknown number of things to cross reference.
- 10 lists of things to check against the unknown number.
I put the lists into arrays before the loop and check each thing against the arrays as it loops and on any hit escape, which seems to work fast enough.
This is all coloring clips by name and the clips are the unknown number. As I tested my first code with a real world project it crawled to a halt doing the referencing. The second code seems to work faster. This is one of those cases where Javascript is clearly not as fast as C++ or similar, so you have to be very aware of coding efficiency or methods.
Your other function below was perfect, thanks. It's puzzling that JS has no inherent routine for that. In VB/C# RGB() color objects auto-resolve to their integer / decimal counterparts with no additional math. You can just debug print or quick watch rgb(23,355,67) or similar and get that number.
Code:
this.getColorCode = function (red, green, blue) {
var blue = blue * 256 * 256;
var green = green * 256;
return red + green + blue;
}