Category: Tips

Useful HexColor Extract Code

This code help me solve many cool effect and also shorten my writing. Also sometime it is easily to forget so here is another good tips to note on here 🙂

var colour:uint = 0xFF297400;
var A:Number = colour >> 24 & 0xFF;
var R:Number = colour >> 16 & 0xFF;
var G:Number = colour >> 8 & 0xFF;
var B:Number = colour & 0xFF;

// RGB
var colourRBG:uint = (R << 16 | G << 8 | B);

// ARGB
var colourARBG:uint = (A << 24 | R << 16 | G << 8 | B);

Radians & Degrees

This math always come back to me after a certain of time and take me 5 – 10 minutes to think or look around the correct one. So I write this down for myself and others for save time to look around.

radians = degrees * Math.PI / 180
degrees = radians * 180 / Math.PI

P.S.
360 degrees = 2 * Math.PI (radian)