# Array syntax error or sheer impossibility?

**URL:** <https://forum.kirupa.com/t/array-syntax-error-or-sheer-impossibility/261832>\
**Category:** Uncategorized\
**Created:** [May 31, 2008, 12:45pm UTC](https://forum.kirupa.com/t/array-syntax-error-or-sheer-impossibility/261832 "2008-05-31T12:45:29Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [May 31, 2008, 12:45pm UTC](https://forum.kirupa.com/t/array-syntax-error-or-sheer-impossibility/261832/1 "2008-05-31T12:45:29Z")

</div>

ok, I got this doubt wich is kinda making me wonder for a while. :huh:

:block:\*\*scenario: \*\*  
\_I’ve got a movieclip with a bunch of buttons inside that invoke a function and send parameters to it. no sweat so far.  
\_those buttons are named with a specific word followed by “\_btn”. that word is the same as the one that goes in the parameter. for example:

```auto
**gobbledigook** _btn.onRelease = function() {[INDENT]_root.myFunction( **gobbledigook** )
[/INDENT]}

```

:wt: **question:**  
I’d like to be this work with a for loop, so I don’t have to repeat the code for every button. so this is what I did:

```auto
_root.wordsList = ["bafflegab", "esculent", "kakistocracy", "palimpsest", "quincux"]

for(i=0;i<_root.wordsList.length;i++){
    [_root.wordsList*+"_btn"].onRelease = function() {
        _root.myFunction(_root.wordsList*);
    }
}

```

now, I’ve searched for array syntax and all, but I can’t get this to work, so my question is becoming “can this be done at all?!” :ne:

answers, anyone?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [May 31, 2008, 1:24pm UTC](https://forum.kirupa.com/t/array-syntax-error-or-sheer-impossibility/261832/2 "2008-05-31T13:24:30Z")

</div>

Yes and no.

```auto

function mooCow():Void {
  trace("called moo!");
};

var fncList:Array = [mooCow];

btn.onRelease = fncList[0];

```

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [May 31, 2008, 1:38pm UTC](https://forum.kirupa.com/t/array-syntax-error-or-sheer-impossibility/261832/3 "2008-05-31T13:38:52Z")

</div>

```auto
for(i=0;i<_root.wordsList.length;i++){
    _root[wordsList*+"_btn"].id = i;
    _root[wordsList*+"_btn"].onRelease = function() {
        _root.myFunction(_root.wordsList[this.id]);
    }
}

```
