all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

changing colour dinamically



changing colour dinamically VooDoo Chicken
2/15/2006 11:41:07 PM
flash actionscript: hi, the problem is as follows: beginfill gets colour parameter as 0xrgb hex, i
want to 'calculate' the colour that should be in the fill, and it would be a
bother to make a function just to create a hex string to pass as parameter and
then pass it as evaluate (something) or whatever, is there any way to 'quickly'
convert a numerial value into a value that can be passed as the colour
parameter into begin fill?
tnx
Re: changing colour dinamically Peter Blumenthal
2/16/2006 12:00:00 AM
It's fairly trivial to convert decimal to hex and back again:

var nDecimal = 16711935;
// Convert DECIMAL to HEX
var nHex = "0x"+nDecimal.toString(16);
trace(nDecimal+" as HEX = "+nHex);
// Convert HEX to DECIMAL
var nDecimalFromHex = parseInt(nHex, 16);
trace("and "+nHex+" as DECIMAL = "+nDecimalFromHex);

Things become a trifle more complex if you want to seperate out the RBG
components of the hex value, perform operations on them and recombine them -
you then need to start looking at bitwise operators and bitwise 'ands' and
'ors'...

--
-------------------------------
Remove '_spamkiller_' to mail
-------------------------------

Re: changing colour dinamically kglad
2/16/2006 12:34:01 AM
Re: changing colour dinamically VooDoo Chicken
2/17/2006 8:28:20 PM
AddThis Social Bookmark Button