# (MX pro 2004) the YET AGAIN and exhausting 'disable button' dilema!

**URL:** <https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430>\
**Category:** flash\
**Created:** [April 13, 2006, 10:17am UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430 "2006-04-13T10:17:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 10:17am UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/1 "2006-04-13T10:17:51Z")

</div>

Hello to all!

I’ve done a search for ‘disable buttons’ and found lots, but am not sure how to go about the situation with my code! Below is my code on 1 of 9 buttons. Once the button is clicked, indeed it is disabled but as with most people I want that button to become active again once the next button is clicked. Other than me writing: [COLOR=blue]\_root.btns\_cntr.profile\_btn.enabled = true;[/COLOR] for each button and placing in every buttons code…is there something else I can do?

\_root.btns\_cntr.profile\_btn.onRelease = function() {  
[COLOR=blue]\_root.btns\_cntr.profile\_btn.enabled = false;  
[/COLOR] \_root.homepage\_cntr.\_visible = 0;  
\_root.sub\_cntr.unloadMovie([COLOR=red]movie[/COLOR]);  
\_root.main\_cntr.loadMovie([COLOR=red]“profile.swf”[/COLOR]);  
\_root.main\_cntr.\_alpha = 0;  
\_root.main\_cntr.alphaTo(100,1,“easeOutCubic”);}

If in the UK…wishing you all a jolly bank holiday weekend! :flower:  
Claire

---

<div class="post-metadata">

**Author:** ![NovemberRain](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@NovemberRain](https://forum.kirupa.com/u/NovemberRain)\
**Post date:** [April 13, 2006, 10:30am UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/2 "2006-04-13T10:30:33Z")

</div>

> [@Claire\_murphy](#):
>
> Hello to all!
> 
> I’ve done a search for ‘disable buttons’ and found lots, but am not sure how to go about the situation with my code! Below is my code on 1 of 9 buttons. Once the button is clicked, indeed it is disabled but as with most people I want that button to become active again once the next button is clicked. Other than me writing: [COLOR=blue]\_root.btns\_cntr.profile\_btn.enabled = true;[/COLOR] for each button and placing in every buttons code…is there something else I can do?
> 
> \_root.btns\_cntr.profile\_btn.onRelease = function() {  
> [COLOR=blue]\_root.btns\_cntr.profile\_btn.enabled = false;  
> [/COLOR]\_root.homepage\_cntr.\_visible = 0;  
> \_root.sub\_cntr.unloadMovie([COLOR=red]movie[/COLOR]);  
> \_root.main\_cntr.loadMovie([COLOR=red]“profile.swf”[/COLOR]);  
> \_root.main\_cntr.\_alpha = 0;  
> \_root.main\_cntr.alphaTo(100,1,“easeOutCubic”);}
> 
> If in the UK…wishing you all a jolly bank holiday weekend! :flower:  
> Claire

You can write a function do activate and deactive the buttons. something like this…

```auto

bArray = [b0, b1, b2, b3, b4, b5, b6, b7];
function disableButtons (disableMe) {
 for (i=0; i<bArray.length; i++) {
  bArray*.enabled = true;
 }
 disableMe.enabled = false;
}

```

store the buttons in an array. Intially all the buttons enabled and passingvalues status turned to false. YOu can set more arguments for loading external movie, alpha and so on. :ear:

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 11:31am UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/3 "2006-04-13T11:31:45Z")

</div>

This sounds great, and i’ve set it up in my AS but i’m not entirely sure whats what. is it possible to explain the code. I’m still a newbie you see! :ponder:

e.g. where do i reference which button i want disabled?

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 13, 2006, 12:50pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/4 "2006-04-13T12:50:01Z")

</div>

eg

```auto
b1.onRelease = function(){
   disableButtons(this);
}

```

or if you don’t want to write it for evrey button

```auto
bArray = [b0, b1, b2, b3, b4, b5, b6, b7];
for (var i = 0; i<bArray.length; i++) {
	var btn = this["b"+i];
	btn.onRelease = function() {
		disableButtons(this);
	};
}

```

scotty(-:

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 12:55pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/5 "2006-04-13T12:55:29Z")

</div>

Not so sure that answered my last query. :m2:  
I find I get on better if I can understand what each bit of the code does so I dont have to post on here for every little thing. I’ve used arrays before but this:

for (var i = 0; i\<bArray.length; i++) {  
var btn = this[“b”+i];

I dont get!

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 13, 2006, 1:15pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/6 "2006-04-13T13:15:51Z")

</div>

for (var i = 0; i\<bArray.length; i++){ This means:  
Make a new variable named “i”(var i = 0), while “i” is less than the length of the array(i\<bArray.length), Incriment “i” every time you run the code(i++).

It will loop through the code below until “i” equals the length of the array. Then it will stop.

var btn = this[“b”+i]  
that is to make a variable out of the given button in the array, so that during the loop you can refer to “btn” instead of “[“b”+i]”.

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 13, 2006, 1:17pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/7 "2006-04-13T13:17:15Z")

</div>

trace is your friend 🙂  
btn is a variable that stands for each button while your looping

```auto
for (var i = 0; i<bArray.length; i++) {
    var btn = this["b"+i];
    trace(btn);
}

```

watch your output window;)

scotty(-:

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 1:29pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/8 "2006-04-13T13:29:50Z")

</div>

Ok so the code is explained…give me time, it’ll sink in:puzzled: hehe  
This is what I have: / /…but where does each bit of code go in conjunction with my button code! sorry for being a dumb-\*\*\*!

btnArray = [home\_btn, profile\_btn, services\_btn, products\_btn, weddings\_btn,colour\_btn, rates\_btn, book\_btn, contact\_btn];

function disableButtons (disableMe) {  
for (i=0; i\<btnArray.length; i++) {  
btnArray\*.enabled = true;  
}  
disableMe.enabled = false;  
}

[COLOR=“DarkRed”]My code on button:[/COLOR]  
\_root.btns\_cntr.profile\_btn.onRelease = function() {  
\_root.homepage\_cntr.\_visible = 0;  
\_root.sub\_cntr.unloadMovie(movie);  
\_root.main\_cntr.loadMovie(“profile.swf”);  
\_root.main\_cntr.\_alpha = 0;  
\_root.main\_cntr.alphaTo(100,1,“easeOutCubic”);}

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 13, 2006, 1:52pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/9 "2006-04-13T13:52:45Z")

</div>

Try this

```auto
btnArray = [btns_cntr.home_btn, btns_cntr.profile_btn, sbtns_cntr.ervices_btn, btns_cntr.products_btn, btns_cntr.weddings_btn, btns_cntr.colour_btn, btns_cntr.rates_btn, btns_cntr.book_btn, btns_cntr.contact_btn];
function disableButtons(disableMe) {
	for (i=0; i<btnArray.length; i++) {
		var btn = btnArray*;
		btn.enabled = true;
	}
	disableMe.enabled = false;
}
_root.btns_cntr.profile_btn.onRelease = function() {
	_root.homepage_cntr._visible = 0;
	_root.sub_cntr.unloadMovie(movie);
	_root.main_cntr.loadMovie("profile.swf");
	_root.main_cntr._alpha = 0;
	_root.main_cntr.alphaTo(100, 1, "easeOutCubic");
	//add this line in all your button actions:
	disableButtons(this);
};

```

scotty(-:

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 2:19pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/10 "2006-04-13T14:19:51Z")

</div>

No Joy! :stunned:

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 13, 2006, 2:24pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/11 "2006-04-13T14:24:45Z")

</div>

post your .fla?

scotty(-:

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 2:28pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/12 "2006-04-13T14:28:25Z")

</div>

It’s a tad too big to send on here! 👁

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 13, 2006, 3:45pm UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/13 "2006-04-13T15:45:40Z")

</div>

any chance I can send it directly to you?

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 14, 2006, 7:11am UTC](https://forum.kirupa.com/t/mx-pro-2004-the-yet-again-and-exhausting-disable-button-dilema/185430/14 "2006-04-14T07:11:34Z")

</div>

Check your PM 😉

scotty(-:
