# Make button work only according to Array

**URL:** https://forum.kirupa.com/t/make-button-work-only-according-to-array/289424
**Category:** flash
**Created:** [May 30, 2009, 2:23am UTC](https://forum.kirupa.com/t/make-button-work-only-according-to-array/289424 "2009-05-30T02:23:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Tyg3r](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tyg3r/32/1341_2.png) [@Tyg3r](https://forum.kirupa.com/u/Tyg3r)
#### Post date: [May 30, 2009, 2:23am UTC](https://forum.kirupa.com/t/make-button-work-only-according-to-array/289424/1 "2009-05-30T02:23:57Z")

</div>

Hi there,

I’m attempting to allow \*\*only \*\*the buttons that are in my array work during MOUSE\_OVER.

The tricky thing for me is identifieing more than one button in the same _if statement_. Does the onButtonOver function need to be in a _ **for loop** _?

Appologies if this is a noobie question.

```auto
var myArray=[3, 4];

for (var i:int = 0; i < buttonArray.length; i++) {
	this["btn"+i].addEventListener(MouseEvent.MOUSE_OVER, onButtonOver);
	this["btn"+i].buttonMode=true;
	this["btn"+i].mouseChildren=false;
	this["btn"+i].button=i;
}

function onButtonOver(e:MouseEvent):void {
	if (e.currentTarget.button == this["btn"+myArray]) {
		trace ("Only button number 3 and 4 will work");
	}
}

```

Thank you all.

Mark
