Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to disable buttons when another button is clicked

Guest
May 08, 2008 May 08, 2008
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
379
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2008 May 08, 2008
you can use the enabled property of movieclips and buttons to enable and disable your buttons.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2008 May 08, 2008
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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2008 May 08, 2008
LATEST
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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines