# Creating an array to disable a group of buttons

**URL:** <https://forum.kirupa.com/t/creating-an-array-to-disable-a-group-of-buttons/318832>\
**Category:** Uncategorized\
**Created:** [January 31, 2011, 11:03pm UTC](https://forum.kirupa.com/t/creating-an-array-to-disable-a-group-of-buttons/318832 "2011-01-31T23:03:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smm11](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@smm11](https://forum.kirupa.com/u/smm11)\
**Post date:** [January 31, 2011, 11:03pm UTC](https://forum.kirupa.com/t/creating-an-array-to-disable-a-group-of-buttons/318832/1 "2011-01-31T23:03:34Z")

</div>

Hi.  
New at AS3, more of a designer than coder but I try.

I have **6 main buttons** and 50 other buttons.  
When people click on one of the six main buttons, I need the 50 other buttons labeled from t\_1 to t\_50 to be disabled (mouseEnabled=false).I should add that all 50 buttons are in a sub group:this.wholeTree.t\_1

I don’t want to write the same line of code 50 times so I’m trying something like this. This is the code for button#6:

butt6.addEventListener(MouseEvent.CLICK,menu6Handler);  
function menu6Handler(e:MouseEvent):void  
{

```
if(this.menu6.currentFrame==15){
menu6.gotoAndPlay(16);
loader.load(new URLRequest("blank.swf"));
for (var i = 1; i &lt; 51; i++)
{
    this.wholeTree["t_" + i].mouseEnabled = true;
}

}else{
loader.load(new URLRequest("blank.swf"));
menu6.gotoAndPlay(2);
menu2.gotoAndStop(1);
menu1.gotoAndStop(1);
menu3.gotoAndStop(1);
menu4.gotoAndStop(1);
menu5.gotoAndStop(1);
for (var i = 1; i &lt; 51; i++)
{
    this.wholeTree["t_" + i].mouseEnabled = false;
}

```

}  
}

This returns 2 errors:  
The first one is **warning 3596 Duplicate variable definition:**  
I tried assigning the variable definition just once at the beginning of the function but then it no longer works and the buttons 1 to 50 don’t get disabled.  
The second error is TypeError: \*\*Error #1010: A term is undefined and has no properties.\*\*at main\_Sustainability\_fla::MainTimeline/menu6Handler()

Help…  
Thanks.
