You could try.
Var col = 0xffeeee;
Var redmask = 0xff0000;
Var greenmask = 0x00ff00;
Var bluemask = 0x0000ff

R = col && redmask;
G = col && greenmask;
B = col & bluemask;
R = R >> 16;
G = G >> 8;
//Blue does not need shifting.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of AliasT
Sent: Wednesday, March 21, 2007 1:22 PM
To: Flashcoders mailing list
Subject: [Flashcoders] Annoying, (should be simple) bitwise problem

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

Reply via email to