Getting Red from my color
I have a situation where I want to manipulate colors in flash.
The idea is that the colors will cross fade nicely from one shade to another.
While you can define colors like this: 0xef556ef
that is stored as a unit data type.
Looking at the above string, it's 8 char in length.
The first two "0x" tell flash to treat this string as a hexadecimal value.
the next two "ef" are the red value, the next two "55" are green and the last 2 "ef" are blue.
Given the above value, I wanted to get the red shade of it, and only the red shade.
This is what I came up with:
//convert the color to a string on a hex base and get the first 2 chars with "0x" at the front
var redValueString :String = "0x" + myColor.toString( 16 ).substr(0,2);
trace( redValueString );
//convert the sting to the int value
var redValueInt : int = int( redValueString );
trace( redValueInt.toString() );
This does give me the result, which is good, but I'm no flash pro, so is there a better (right?) way to do it?
Feel free to tell me if there is!
