How can I convert a RGB color into a HEX in AS3?. For example: R=253 G=132 B=58.
Tks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Robusto’s solution is too slow.
Because RGB values are stored like this:
And a value of 0-255 (that is not a coincidence) has 8b too, you can use left bitwise shifts to get the int value, and THEN you can get a hex (almost 3 times faster). So:
Where red, green and blue are the values of RGB that you want to convert.