Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Click to change color of field

Avatar

Former Community Member
When a user clicks a field I want the color to change. Each click will result in a different color (of 5). I assume I need an array but am currently unable to get it to work.



I have the following code on a mouseUp:



function changeColor()

{

var changeColor= new Array(5)

changeColor[0]="10,100,50";

changeColor[1]="100,120,70";

changeColor[2]="80,10,30";

changeColor[3]="20,120,65";

changeColor[4]="15,150,50";

var x=0;

for (x=0; x<5; x++)

{

TextField1.fillColor = changeColor[x];}

}
7 Replies

Avatar

Former Community Member
Found your issue .....x and y are reserved expressions (used to define the location of the field). Change it to i and it will work just fine.

Avatar

Former Community Member
Worked for me ....post your email address and I will send you a sample.

Avatar

Former Community Member
Hmm. It changes to one shade of green and doesn't change again. So for you it changes color on each click? What am I doing wrong here?

Avatar

Former Community Member
Its running through all 5 colors in the array and the last one is being displayed. It is not setting it to the 0 color on the 1st click etc...