Hi Alias, it's either % 256 or & 255. But % 255 gives you the wrong result -- (255 % 255 == 0).
Either: var r = col >> 16; var g = (col >> 8) % 256; var b = col % 256; Or: var r = col >> 16; var g = (col >> 8) & 0xff; var b = col & 0xff; I prefer the second. HTH, Mark On 3/21/07, Alias™ <[EMAIL PROTECTED]> wrote:
Hi guys, This is annoying me - I'm just trying to get the seperate RGB component values out of a hex number, then manipulate and reconstruct them. var col = 0xFFEEEE; r = col >> 16; g = col >> 8 % 255; b = col % 255; trace("r="+r.toString(16)); trace("g="+g.toString(16)); trace("b="+b.toString(16)); col2 = r <<16 + g << 8 + b; trace("col2="+col2.toString(16)); Anyone got any idea why this isn't working right? My blue values are doing all sorts of wierd stuff - getting smaller, flipping out etc - is it a modulo problem maybe? Should be simple but this always gets me... Any help much appreciated, Alias _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com