Re: [Flashcoders] Annoying, (should be simple) bitwise problem
Give this a shot function getRGB(c:Number):Array { return [c>>>16, c>>8&~0xFF00, c&~0xF00]; } 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 = 0xFF; 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
Re: [Flashcoders] Annoying, (should be simple) bitwise problem
Hi buddy, isnt the format ARGB ? HEX = 0x AA RR GG BB ? Just a suggestion :) But I think what you think are your blues ar ein reality your Greens :) Also dependant on the version of flash you are working with... Best of Luck and successfull clicking Amir Am 07:21 PM 3/21/2007 schrieben Sie: 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 = 0xFF; 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
Re: [Flashcoders] Annoying, (should be simple) bitwise problem
there might be more clever ways... var col = 0x0199FF; var _r = (col>> 16); var _g = (col>> 8 ^ _r << 8); var _b = (col^ (_r << 16 | _g << 8)); trace("r="+_r); trace("g="+_g); trace("b="+_b); var r = (_r.toString(16).length < 2) ? "0"+_r.toString(16) : _r.toString(16); var g = (_g.toString(16).length < 2) ? "0"+_g.toString(16) : _g.toString(16); var b = (_b.toString(16).length < 2) ? "0"+_b.toString(16) : _b.toString(16); var hexa="0x"+r+g+b trace("hexa="+hexa) 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
Re: [Flashcoders] Annoying, (should be simple) bitwise problem
there's an old article on the adobe dev center that talks all about this... go check it out: http://www.adobe.com/devnet/flash/articles/bitwise_operators.html On Mar 21, 2007, at 2:21 PM, Alias™ 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 = 0xFF; 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
RE: [Flashcoders] Annoying, (should be simple) bitwise problem
var col = 0xFF; r = col >> 16; g = (col >> 8) & 0xff; b = col & 0xff; var col2 = r << 16 | g << 8 | b; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alias(tm) 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 = 0xFF; 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
Re: [Flashcoders] Annoying, (should be simple) bitwise problem
Use & instead of % r = (col >> 16) & 0xFF; g = (col >> 8) & 0xFF; b = col & 0xFF; Glen :) Alias™ 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 = 0xFF; 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
Re: [Flashcoders] Annoying, (should be simple) bitwise problem
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 = 0xFF; 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
RE: [Flashcoders] Annoying, (should be simple) bitwise problem
You could try. Var col = 0xff; Var redmask = 0xff; Var greenmask = 0x00ff00; Var bluemask = 0xff 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 = 0xFF; 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