3 Replies Latest reply on May 11, 2010 8:04 AM by web_amy

    Holding button in "down" state

    web_amy

       

      I'm using this code from a previous thread on this site, it was extremely helpful (thanks Ned). I was able to get it to work when the buttons were placed on the timeline, but now I have a the movieclip embedded into two movieclips and can't get it to work.The buttons are holding in the down state but not resetting. I'm sure it's a path issue, but can't seem to get it to work. Any pointers? Here's the script I have on the timeline:

       

      function resetBtns(btnNum){
          for(i=1; i<4; i++){
              if(i != btnNum){
                  this["btn"+i+"Selected"] = false;
                  this["btn"+i].gotoAndStop("up");
              }
          }
      }

       

      var btn1Selected = false;
      var btn2Selected = false;
      var btn3Selected = false;

       

      my_acc.Customer1_select.btn1.onRollOver = function(){
          if(!my_acc.Customer1_select.btn1Selected) my_acc.Customer1_select.btn1.gotoAndStop("over");

      }

       

      my_acc.Customer1_select.btn1.onRollOut = my_acc.Customer1_select.btn1.onReleaseOutside = function(){
          if(!my_acc.Customer1_select.btn1Selected) my_acc.Customer1_select.btn1.gotoAndStop("up");

      }

       

      my_acc.Customer1_select.btn1.onPress = function(){
          my_acc.Customer1_select.btn1.gotoAndStop("down");
      }

       

      my_acc.Customer1_select.btn1.onRelease = function(){
          resetBtns(1);
          my_acc.Customer1_select.btn1Selected = true;

      }

       

      my_acc.Customer1_select.btn2.onRollOver = function(){
          if(!my_acc.Customer1_select.btn2Selected) my_acc.Customer1_select.btn2.gotoAndStop("over");

      }

       

      my_acc.Customer1_select.btn2.onRollOut = my_acc.Customer1_select.btn2.onReleaseOutside = function(){
          if(!my_acc.Customer1_select.btn2Selected) my_acc.Customer1_select.btn2.gotoAndStop("up");

      }

       

      my_acc.Customer1_select.btn2.onPress = function(){
          my_acc.Customer1_select.btn2.gotoAndStop("down");
      }

       

      my_acc.Customer1_select.btn2.onRelease = function(){
          resetBtns(2);
          my_acc.Customer1_select.btn2Selected = true;

      }

       

      my_acc.Customer1_select.btn3.onRollOver = function(){
          if(!my_acc.Customer1_select.btn3Selected) my_acc.Customer1_select.btn3.gotoAndStop("over");

      }

       

      my_acc.Customer1_select.btn3.onRollOut = my_acc.Customer1_select.btn3.onReleaseOutside = function(){
          if(!my_acc.Customer1_select.btn3Selected) my_acc.Customer1_select.btn3.gotoAndStop("up");

      }

       

      my_acc.Customer1_select.btn3.onPress = function(){
          my_acc.Customer1_select.btn3.gotoAndStop("down");
      }

       

      my_acc.Customer1_select.btn3.onRelease = function(){
          resetBtns(3);
          my_acc.Customer1_select.btn3Selected = true;

      }

        • 1. Re: Holding button in "down" state
          kglad Adobe Community Professional & MVP

          try:

           


           

          function resetBtns(btnNum){
              for(i=1; i<4; i++){
                  if(i != btnNum){
                    my_acc.Customer1_select["btn"+i]= false;

                     my_acc.Customer1_select["btn"+i].gotoAndStop("up");
                  }
              }
          }

           

          var btn1Selected = false;
          var btn2Selected = false;
          var btn3Selected = false;

           

          my_acc.Customer1_select.btn1.onRollOver = function(){
              if(!my_acc.Customer1_select.btn1Selected) my_acc.Customer1_select.btn1.gotoAndStop("over");

          }

           

          my_acc.Customer1_select.btn1.onRollOut = my_acc.Customer1_select.btn1.onReleaseOutside = function(){
              if(!my_acc.Customer1_select.btn1Selected) my_acc.Customer1_select.btn1.gotoAndStop("up");

          }

           

          my_acc.Customer1_select.btn1.onPress = function(){
              my_acc.Customer1_select.btn1.gotoAndStop("down");
          }

           

          my_acc.Customer1_select.btn1.onRelease = function(){
              resetBtns(1);
              my_acc.Customer1_select.btn1Selected = true;

          }

           

          my_acc.Customer1_select.btn2.onRollOver = function(){
              if(!my_acc.Customer1_select.btn2Selected) my_acc.Customer1_select.btn2.gotoAndStop("over");

          }

           

          my_acc.Customer1_select.btn2.onRollOut = my_acc.Customer1_select.btn2.onReleaseOutside = function(){
              if(!my_acc.Customer1_select.btn2Selected) my_acc.Customer1_select.btn2.gotoAndStop("up");

          }

           

          my_acc.Customer1_select.btn2.onPress = function(){
              my_acc.Customer1_select.btn2.gotoAndStop("down");
          }

           

          my_acc.Customer1_select.btn2.onRelease = function(){
              resetBtns(2);
              my_acc.Customer1_select.btn2Selected = true;

          }

           

          my_acc.Customer1_select.btn3.onRollOver = function(){
              if(!my_acc.Customer1_select.btn3Selected) my_acc.Customer1_select.btn3.gotoAndStop("over");

          }

           

          my_acc.Customer1_select.btn3.onRollOut = my_acc.Customer1_select.btn3.onReleaseOutside = function(){
              if(!my_acc.Customer1_select.btn3Selected) my_acc.Customer1_select.btn3.gotoAndStop("up");

          }

           

          my_acc.Customer1_select.btn3.onPress = function(){
              my_acc.Customer1_select.btn3.gotoAndStop("down");
          }

           

          my_acc.Customer1_select.btn3.onRelease = function(){
              resetBtns(3);
              my_acc.Customer1_select.btn3Selected = true;

          }

          • 2. Re: Holding button in "down" state
            web_amy Level 1

            Thanks for your help, but unfortunately that didn't work.The Rollover and Rollout and hold worked on the first button, but didn't work for the other two buttons. It also didn't reset when clicked. Thanks for taking the time though, I really appreciate it!

            • 3. Re: Holding button in "down" state
              web_amy Level 1

              I figured out the issue, via this thread: http://forums.adobe.com/message/2034833#2034833