I can’t get code in my button to change the values displayed in my dynamic text boxes.
I have a column of twelve dynamic text boxes which display numbers stored in an array. The array contains more than twelve numbers. I want to use buttons to refresh the information in the boxes (effectively creating a scrolling effect) so that the remaining contents of the array can be revealed as required. In the code below Stats1 etc. refer to the dynamic text. The array is called Stats4display. This shows the information fine.
The button (in the same timeline on a different layer) has this code:
on (release) {
x++;
}
I had hoped that by incrementing the value of x I could update all the dynamic text boxes with the next value along in the array. Why doesn’t this work? Some kind of scoping problem? Or is there an easier way to do this?
First of all, this loop is equivalent to your group of 13 assignments:
for (var i = 0; i <13; ++i)
{
eval("Stat"+(i+1)) = Stats4display[x+i];
}
Secondly, incrementing x will only have an effect if after you increment x, you re-execute the code that does the assignments. Once the assignments are performed, they don’t get automatically adjusted when you increment x.
Like so:
on (release) {
x++;
for (var i = 0; i <13; ++i)
{
eval("Stat"+(i+1)) = Stats4display[x+i];
}
}