# AS3 -For Loop Problems With Buttons

**URL:** <https://forum.kirupa.com/t/as3-for-loop-problems-with-buttons/268936>\
**Category:** flash\
**Created:** [August 20, 2008, 4:33pm UTC](https://forum.kirupa.com/t/as3-for-loop-problems-with-buttons/268936 "2008-08-20T16:33:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrmike](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@mrmike](https://forum.kirupa.com/u/mrmike)\
**Post date:** [August 20, 2008, 4:33pm UTC](https://forum.kirupa.com/t/as3-for-loop-problems-with-buttons/268936/1 "2008-08-20T16:33:29Z")

</div>

Hi,

I’m trying to add event listeners to 80 buttons and I do not want to do this one by one so I tried to put it in a For loop but keep getting this error:

[COLOR=Red]Error #1006: value is not a function.[/COLOR]

Here Is My Code:

```auto

function showMatte(num){
    // do something with the returned "num"
}

for (i=1; i<80; i++){
    var me = "m" + i;
    trace(me)
    me.addEventListener(MouseEvent.CLICK,changeMatte); // doesn't get past this point
    function changeMatte(ev:MouseEvent):void{
        trace(i);
        showMatte(i);
    }
    i++;
}

```

Any help or references would be appreciated.

Thanks
