0
how to disable buttons when another button is clicked

/t5/animate-discussions/how-to-disable-buttons-when-another-button-is-clicked/td-p/926313
May 08, 2008
May 08, 2008
Copy link to clipboard
Copied
I have an application with 5 buttons that each play or pause
different movieclips. How can I prevent other buttons from playing
different movieclips when a movieclip is already playing.
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/how-to-disable-buttons-when-another-button-is-clicked/m-p/926314#M252161
May 08, 2008
May 08, 2008
Copy link to clipboard
Copied
you can use the enabled property of movieclips and buttons to
enable and disable your buttons.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/animate-discussions/how-to-disable-buttons-when-another-button-is-clicked/m-p/926315#M252162
May 08, 2008
May 08, 2008
Copy link to clipboard
Copied
I looked in the help and found an example actionscript. I
changed the button instance names to the button names in my app. I
put the actionscript on frame 1 that holds the movieclip being
played. Here it is
{
mycase3_btn = true;
mycase1_btn = false;
mycase2_btn = false;
//button code
// the following function will not get called
// because myBtn2_btn.enabled was set to false
mycase1_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
mycase2_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
mycase3_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
}
It doesn't disable the other 2 buttons. As may be obvious I am new to all but the simplest actionscripts. What am I doing wrong?
thank you for your time!
{
mycase3_btn = true;
mycase1_btn = false;
mycase2_btn = false;
//button code
// the following function will not get called
// because myBtn2_btn.enabled was set to false
mycase1_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
mycase2_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
mycase3_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
}
It doesn't disable the other 2 buttons. As may be obvious I am new to all but the simplest actionscripts. What am I doing wrong?
thank you for your time!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/animate-discussions/how-to-disable-buttons-when-another-button-is-clicked/m-p/926316#M252163
May 08, 2008
May 08, 2008
Copy link to clipboard
Copied
For what you show, you haven't disabled any of the buttons.
If I get the intention right, you should have...
mycase3_btn.enabled = true;
mycase1_btn.enabled = false;
mycase2_btn.enabled = false;
One way to deal with disabling sets of buttons is to have a function that enables/disables them all, as in...
function enableBtns(truefalse){
for(i=1; i<4; i++){
this["mycase"+i+"_btn"].enabled = truefalse;
}
}
Then, for the button functions, first you call the function to disable them all...
enableBtns(false);
And when the movieclip finishes playing you need to have the buttons enabled again... which you can have in the last frame of the movieclip.
_parent.enableBtns(true);
mycase3_btn.enabled = true;
mycase1_btn.enabled = false;
mycase2_btn.enabled = false;
One way to deal with disabling sets of buttons is to have a function that enables/disables them all, as in...
function enableBtns(truefalse){
for(i=1; i<4; i++){
this["mycase"+i+"_btn"].enabled = truefalse;
}
}
Then, for the button functions, first you call the function to disable them all...
enableBtns(false);
And when the movieclip finishes playing you need to have the buttons enabled again... which you can have in the last frame of the movieclip.
_parent.enableBtns(true);
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

