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

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…


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:

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?

eg

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

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

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(-:

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!

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]”.

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

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

watch your output window;)

scotty(-:

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”);}

Try this

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(-:

No Joy! :stunned:

post your .fla?

scotty(-:

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

any chance I can send it directly to you?

Check your PM :wink:

scotty(-: