3 Replies Latest reply on May 8, 2008 1:20 PM by Ned Murphy

    how to disable buttons when another button is clicked

    roughbern
      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.
        • 1. Re: how to disable buttons when another button is clicked
          kglad Adobe Community Professional & MVP
          you can use the enabled property of movieclips and buttons to enable and disable your buttons.
          • 2. Re: how to disable buttons when another button is clicked
            roughbern Level 1
            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!
            • 3. Re: how to disable buttons when another button is clicked
              Ned Murphy Adobe Community Professional & MVP
              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);