# Help! Clever person needed. Button/Dynamic text problem

**URL:** <https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828>\
**Category:** Uncategorized\
**Created:** [June 11, 2004, 6:36pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828 "2004-06-11T18:36:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boondogger](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@Boondogger](https://forum.kirupa.com/u/Boondogger)\
**Post date:** [June 11, 2004, 6:36pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/1 "2004-06-11T18:36:25Z")

</div>

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.

Stat1=Stats4display[x];  
Stat2=Stats4display[(x+1)];  
Stat3=Stats4display[(x+2)];  
Stat4=Stats4display[(x+3)];  
Stat5=Stats4display[(x+4)];  
Stat6=Stats4display[(x+5)];  
Stat7=Stats4display[(x+6)];  
Stat8=Stats4display[(x+7)];  
Stat9=Stats4display[(x+8)];  
Stat10=Stats4display[(x+9)];  
Stat11=Stats4display[(x+10)];  
Stat12=Stats4display[(x+11)];  
Stat13=Stats4display[(x+12)];

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?

Any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 6:55pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/2 "2004-06-11T18:55:33Z")

</div>

First of all, this loop is equivalent to your group of 13 assignments:

```auto

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:

```auto

on (release) {
  x++;
  for (var i = 0; i <13; ++i)
  {
    eval("Stat"+(i+1)) = Stats4display[x+i];
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 6:56pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/3 "2004-06-11T18:56:17Z")

</div>

Something like this?

```auto
function refreshValues(x) {
	for (var i = 1; i<=13; ++i) {
		this["Stat"+i] = Stats4display[x+i-1];
	}
}
refreshValues(0);
on (release) {
	refreshValues(++x);
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 8:06pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/4 "2004-06-11T20:06:32Z")

</div>

To Jbum,

Thanks a lot for your suggestions.

When I tried what you suggested I got an error message (Left side of assignment operator must be variable or property.)

Why would that be then?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 8:37pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/5 "2004-06-11T20:37:23Z")

</div>

Thanks Claudio,

Where would that code go? In the button or on the main timeline? Sorry I’m a complete newbie. Duh!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 9:11pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/6 "2004-06-11T21:11:57Z")

</div>

On the main timeline:

```auto
function refreshValues(x) {
for (var i = 1; i<=13; ++i) {
this["Stat"+i] = Stats4display[x+i-1];
}
}
refreshValues(0);

```

On the button:

```auto
on (release) {
refreshValues(++x);
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2004, 9:12pm UTC](https://forum.kirupa.com/t/help-clever-person-needed-button-dynamic-text-problem/112828/7 "2004-06-11T21:12:31Z")

</div>

In claudio’s example, everything up to the ‘on (release)’ would likely go in a frame script.

The stuff after and including on(release) should be attached to the button.

Whoops - I see I cross-posted with Claudio. 🙂
