# Functions with arrays

**URL:** <https://forum.kirupa.com/t/functions-with-arrays/329614>\
**Category:** Uncategorized\
**Created:** [September 22, 2012, 8:28am UTC](https://forum.kirupa.com/t/functions-with-arrays/329614 "2012-09-22T08:28:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harry\_kooner2k](https://avatars.discourse-cdn.com/v4/letter/h/6bbea6/32.png) [@harry\_kooner2k](https://forum.kirupa.com/u/harry_kooner2k)\
**Post date:** [September 22, 2012, 8:28am UTC](https://forum.kirupa.com/t/functions-with-arrays/329614/1 "2012-09-22T08:28:27Z")

</div>

function does not works with array in following code:  
in reference image these five are the movieclips on the stage and their instance names are same as the array items. see attachment for reference.

```auto

[LEFT][COLOR=#993300]var[/COLOR] mainBtnsArr:[COLOR=#993300]Array[/COLOR] = [COLOR=#000000][[/COLOR][COLOR=#0000FF]"chapters"[/COLOR], [COLOR=#0000FF]"projects"[/COLOR], [COLOR=#0000FF]"exercises"[/COLOR], [COLOR=#0000FF]"skills"[/COLOR], [COLOR=#0000FF]"glossary"[/COLOR][COLOR=#000000]][/COLOR];  

[COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000000]0[/COLOR]; i<mainBtnsArr.[COLOR=#993300]length[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
   mainBtn = mainBtnsArr[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR];

   mainBtnsArr[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]onPress[/COLOR] = [COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR] 
      [COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"working"[/COLOR][COLOR=#000000])[/COLOR]; 
   [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[/LEFT]

```

Any Help??
