Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

JavaScripting linear fill

mistersing
Level 2
Level 2
Trying to get a linear fill, top to bottom, in a button or field using JavaScripting so I can change the colors when needed. Adobe documentation says it can be done, but is not clear as to how to get the desired result. Any ideas?

Thank you.
3 Replies
pguerett
Level 10
Level 10
Not sure what you mean can you elaborate?
mistersing
Level 2
Level 2
In a button or field you can use the following code to add a fill or background color:



fieldname.border.fill.color.value = "255,0,0";



I would like to be able to do the same thing with a top to bottom linear (gradient) background 2-color fill.
pguerett
Level 10
Level 10
OK now I understand. You will have to setup your field with the appearance the way you want (i.e. Linear toBottom) with white to white before you run your script. This will give the same appearance as a normal field but it will put the neccessary nodes in the XDP to allow you to manipulate them. Once you do this you will need three commands to complete your change.



1. To set the style of the appearance:

TextField1.ui.textEdit.border.fill.linear.type = "to Bottom";



2. Set the color that you are fading to:

TextField1.ui.textEdit.border.fill.linear.color.value = "0,0,255";



3. Set the colro of the field that you are starting from:

TextField1.ui.textEdit.border.fill.color.value = "255,0,0";



Lastly you will need to put fous on the field to have your changes applied:

xfa.host.setFocus("TextField1");