Highlighted

Click to change color of field

Avatar

Guest

19-11-2008

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];}

}

Replies

Highlighted

pguerett

24-11-2008

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.
Highlighted

Avatar

Guest

15-12-2008

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?
Highlighted

pguerett

15-12-2008

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...