# Right way to enable/disable in a for loop

**URL:** <https://forum.kirupa.com/t/right-way-to-enable-disable-in-a-for-loop/310704>\
**Category:** flash\
**Created:** [June 17, 2010, 6:37am UTC](https://forum.kirupa.com/t/right-way-to-enable-disable-in-a-for-loop/310704 "2010-06-17T06:37:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![humbucker](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@humbucker](https://forum.kirupa.com/u/humbucker)\
**Post date:** [June 17, 2010, 6:37am UTC](https://forum.kirupa.com/t/right-way-to-enable-disable-in-a-for-loop/310704/1 "2010-06-17T06:37:55Z")

</div>

Hi guys,

I d’like to have your opinion about the best and effective way to enable/disable properties on a list of MC buttons.

Let’s say I got a menu of 5 MC links and I click on one of them. I want to disable the mouseEnabled propertie on it and change its color. But most important reset all the other ones.

That’s what I have so far but I feel it’s not the best thing to do:

```auto

selectedButtonId = e.target.id (get the id of the clicked button in the buttonsArray)

for (i=0, i<buttonsArray.length, i++) {
buttonsArray*.mouseEnabled = true;
Tweener...[buttonsArray*.....;
}

buttonsArray[selectedButtonId].mouseEnabled = false;
Tweener...buttonsArray[selectedButtonId]....;

```

By using this loop, I sadly first change the properties of the selected button (in the loop) to change them again … sounds useless and time consuming no?

Thanks!
