Skip to main content
adrianTNT
Known Participant
August 1, 2006
Answered

Color code problem

Hello.
I have this code:

colors = [0xFFCC00, 0xFFFF00];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {a:100, b:20, c:5, d:100, e:0, f:10, g:100, h:10, i:5};
beginGradientFill("linear", colors, alphas, ratios, matrix);

I use it to fill a clip with a gradient color.
I want the second color (in first line) to be taken from a variable.
I tried:

my_color = "0x"+"FFFFCC";
colors = [0xFFCC00, my_color];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {a:100, b:20, c:5, d:100, e:0, f:10, g:100, h:10, i:5};
beginGradientFill("linear", colors, alphas, ratios, matrix);

It doesnt work, it doesn't read the variable as a color and the color it sets is black.
Anyone knows how the color code should be composed so that I can have that color code taken from a variable?

Thank you.
- Adrian.
This topic is closed to new replies. Start a new post to keep the conversation going.
RothrockCorrect answer
Inspiring
August 1, 2006
Aha, I see now. Okay how about this:

a_variable="FFCC00"
myColor=parseInt("0x"+a_variable);

6 replies

RothrockCorrect answer
Inspiring
August 1, 2006
Aha, I see now. Okay how about this:

a_variable="FFCC00"
myColor=parseInt("0x"+a_variable);
Translate
adrianTNT
adrianTNTAuthor
Known Participant
August 2, 2006
quote:

Originally posted by: Rothrock
Aha, I see now. Okay how about this:
a_variable="FFCC00"
myColor=parseInt("0x"+a_variable);


Thanks, it looks like that was what I needed there (parseInt).
Translate
Inspiring
August 1, 2006
I'm not certain, but I would try:

my_color=0xFFFFCC;

How does that work for ya?
Translate
adrianTNT
adrianTNTAuthor
Known Participant
August 1, 2006
quote:

Originally posted by: Rothrock
I'm not certain, but I would try:
my_color=0xFFFFCC;
How does that work for ya?

Hi.
That would normally work as you wrote it but I need the color to be made from a variable value that doesnt contain the # or 0x.
So I have a value as "FFCC00" and I cannot merge the 0x with it because it only allows the color code to be added after 0x and not a variable name.

a_variable="FFCC00"
my_color = "0x" + a_variable

that doesnt work. It only works if I type color code directley after the 0x as you said 0xFFCC00.
Do I make sense ? :)
Translate