# Cycle through array on click

**URL:** <https://forum.kirupa.com/t/cycle-through-array-on-click/203275>\
**Category:** Uncategorized\
**Created:** [October 9, 2006, 7:11pm UTC](https://forum.kirupa.com/t/cycle-through-array-on-click/203275 "2006-10-09T19:11:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dru\_nasty](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dru\_nasty](https://forum.kirupa.com/u/dru_nasty)\
**Post date:** [October 9, 2006, 7:11pm UTC](https://forum.kirupa.com/t/cycle-through-array-on-click/203275/1 "2006-10-09T19:11:56Z")

</div>

K, I’ve got 3 different arrays

```auto

var tumbler1:Array = new Array("some stuff","more stuff","and more");

var tumbler2:Array = new Array("text","more text","and more text");

var tumbler3:Array = new Array("yep","yep yep","yep yep yep");

```

Then I’ve got 3 dynamic text fields on the stage with respective variable names so they populate with the first item in each array.

```auto

var t1:String = tumbler1[0];
var t2:String = tumbler2[0];
var t3:String = tumbler3[3];

```

Next I have some buttons on top each text field where I want when say the first button is pressed (btn1, which is over the t1 text field) the next item in the array is used to populate the text field.

```auto

btn1.onRelease = function(){
// in theory i tried this but doesn't work, just get undefined
for (var i=0; i<=tumbler1.length; i++){
	t1 = tumbler1*;
	}
}

```

Also if possible, if the last item in the array was being used, if you click again it’ll start back over at the first item.
