# \[FMX\] for loops and disabling buttons

**URL:** <https://forum.kirupa.com/t/fmx-for-loops-and-disabling-buttons/38178>\
**Category:** flash\
**Created:** [December 19, 2003, 1:34am UTC](https://forum.kirupa.com/t/fmx-for-loops-and-disabling-buttons/38178 "2003-12-19T01:34:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maizoon](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@Maizoon](https://forum.kirupa.com/u/Maizoon)\
**Post date:** [December 19, 2003, 1:34am UTC](https://forum.kirupa.com/t/fmx-for-loops-and-disabling-buttons/38178/1 "2003-12-19T01:34:37Z")

</div>

So…

I have an mc that when you rollover opens a menu system. There are buttons behind this menu system that I would like to have disabled when the menu system is open and re-enabled when the menu system is closed. I have this script on my timeline:  
[AS]  
function lnkenable(isIt) {  
lnk0.enabled = isIt;  
lnk1.enabled = isIt;  
lnk2.enabled = isIt;  
lnk3.enabled = isIt;  
}  
[/AS]  
and on my menu system I have this to turn on/off the buttons:  
[AS]  
on (rollover){  
\_root.lnkenable(false);  
\_root.menu.gotoAndPlay(“open”);  
}  
on(rollOut){  
\_root.lnkenable(true);  
\_root.menu.gotoAndPlay(“closed”);  
}  
[/AS]  
This works as it should, however I would like to add more lnk buttons at a later date and don’t want to keep adding lines of code. How can I execute this with a loop? I tried the following with no effect (the buttons behind the menu still work)  
[AS]  
var lk;  
function lnkenable(isIt) {  
for (lk=0; lk\<4; lk++) {  
lnk[lk].enabled = isIt;  
trace(lk)  
trace(isIt)  
}  
}  
[/AS]  
I’ve not gotten to indepth with for loops and whatnot so I’ve probably butchered this. The script works when I detail each button (ie the top script) but not when I loop through them (ie the bottom script) thanks.

btw…thanks to electrongeek for the code idea
