Copy link to clipboard
Copied
Lets say I have Buttons A and B and text field "Text1" I need code so when I press button A it change fill color of text field to(example green) and when i press button B it change text field to green also but if it is already green(because of button A) then change color to (example red).Can you Guys help pls?
Copy link to clipboard
Copied
You can use this code:
var field1 = this.getField("Text1");
if (color.equal(field1.fillColor, color.green)==true) field1.fillColor = color.red;
else field1.fillColor = color.green;
You didn't specify what should happen if the button is clicked is the field is red, though...
Copy link to clipboard
Copied
You can use this code:
var field1 = this.getField("Text1");
if (color.equal(field1.fillColor, color.green)==true) field1.fillColor = color.red;
else field1.fillColor = color.green;
You didn't specify what should happen if the button is clicked is the field is red, though...
Copy link to clipboard
Copied
Exactly what I needed thanks. Can you tell me also how to change colors to RGB?
Copy link to clipboard
Copied
Sure. Instead of color.green or color.red you can use this:
["RGB", 0, 1, 0]
["RGB", 1, 0, 0]
Note that the values are from 0 to 1, not 0 to 255 like in other places.
Copy link to clipboard
Copied
Thx that did the job.
Copy link to clipboard
Copied
Hi @try67
How could I use these colors instead of green and red:
["RGB", 228, 229, 230]
["RGB", 255, 192, 0]
Copy link to clipboard
Copied
You can use RGB colors like this: ["RGB", 228/255, 229/255, 230/255]
If you want to compare RGB colors using color.equal it's a bit trickier.
Copy link to clipboard
Copied
Thank you, it's working very well
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more