2 Replies Latest reply on Jan 29, 2014 8:37 PM by rossfranks

    Move in y-axis until user stops holding down button?

    rossfranks Level 1

      In my example below is there a way to have the user hold down the orange button and this makes the numbers continually move down in the y-axis until the user stops holding down on the orange button?

       

      http://twistedpancreas.com/edge/misc/mouseDown.zip

       

      Thanks in advance.

        • 1. Re: Move in y-axis until user stops holding down button?
          heathrowe Most Valuable Participant

          Replace your Original Stage trigger action code with this; Comments is appended to the code;

           

          /* Your Original Code
          sym.getComposition().getStage().getSymbol('lab_items').$('btn').bind('mousedown touchstart',function(e){
          sym.getComposition().getStage().getSymbol('lab_items')
          .getSymbol('numbers')
          .$('labMarks')
          .animate({'top':'-=50px' }, 300, 'linear');
          });
          End Your Original Code*/

           

          ///////// New Code   //////////

          // Use a function to hold the continuous scroll animate method.

          // The trick here is with the last parameter scrollCont.

          // Which essentially calls the function (itself) over and over,

          // looping, until mouseup is triggered later

           

          function scrollCont(){
              sym.getComposition().getStage().getSymbol('lab_items')
          .getSymbol('numbers')
          .$('labMarks')
          .animate({'top':'-=50px' }, 300, 'linear', scrollCont);
          }

           

          // Function to stop() the continuous scrolling when

          // mouseup is trigger, later

           

          function stopScroll(){
              sym.getComposition().getStage().getSymbol('lab_items')
          .getSymbol('numbers')
          .$('labMarks').stop();
          }

           

          // Your mousedown touchstart still applies; the addition event

          // chaining the mouseup touchend; which

          // when triggered will fire the stopScroll() function.

           

          sym.getComposition().getStage().getSymbol('lab_items').$('btn').bind('mousedown touchstart',function(e){
              scrollCont();
          }).bind('mouseup touchend', function(e) {
              stopScroll();
          });

          ////// End New Code ///////

           

          hth

          Darrell

          • 2. Re: Move in y-axis until user stops holding down button?
            rossfranks Level 1

            You are the man!

             

            Exactly what I was after and so simple to understand, thanks bigtime heathrowe !!!