# Setting up functions to go with an array

**URL:** https://forum.kirupa.com/t/setting-up-functions-to-go-with-an-array/295949
**Category:** Uncategorized
**Created:** [September 7, 2009, 8:52pm UTC](https://forum.kirupa.com/t/setting-up-functions-to-go-with-an-array/295949 "2009-09-07T20:52:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jumpsuit1](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jumpsuit1](https://forum.kirupa.com/u/jumpsuit1)
#### Post date: [September 7, 2009, 8:52pm UTC](https://forum.kirupa.com/t/setting-up-functions-to-go-with-an-array/295949/1 "2009-09-07T20:52:26Z")

</div>

Hi there,

I have an array that I have set up that would go with a series of movie clips, and I am trying to combine them with functions that upload xml pictures–firstImage(), secondImage(), and so forth.

Here is the array that I have:

```auto
var currentButtonId:Number = 0;
var buttons:Array = [btn1, btn2, btn3, btn4, btn5, btn6];

function buttonRelease() {
    for(var i:Number = 0; i < buttons.length; i++) {
        if(this.id == buttons*.id) {
            currentButtonId = i;
			buttons*.index = i;
            buttons*.gotoAndStop(2);
            buttons*.enabled = false;
            trace(i);
        } else {
            buttons*.gotoAndStop(1);
            buttons*.enabled = true;
        }
    }
} 

jms_btn.id = 1;
tkno_btn.id = 2;
kofi_btn.id = 3;
bolle_btn.id = 4;
don_btn.id = 5;
nchil_btn = 6;
jms_btn.onRelease = buttonRelease;
tkno_btn.onRelease = buttonRelease;
kofi_btn.onRelease = buttonRelease;
bolle_btn.onRelease = buttonRelease;
don_btn.onRelease = buttonRelease;
nchil_btn.onRelease = buttonRelease;

```

It enables and disables the movieclips depending on which one is clicked. But I want to make the xml functions (firstImage(), secondImage()…) go with the buttons in sequence. So once btn1 gets pressed the firstImage() xml function gets called.
