3 Replies Latest reply on Aug 24, 2011 5:11 AM by mattdwm

    Scroller component speed

    mattdwm Level 1

      Does anyone have any tips for dealing with the speed of the Scroller component (the mouse wheel speed specifically). It scrolls either way to fast or way to slow.

        • 1. Re: Scroller component speed
          _spoboyle Level 4

          I had a similar issue and implemented a fixed speed scroller (i.e. not dependant on scroller height/width)

           

          subclass VScrollBar/HScrollBar

           

          add the following function (this is my code for the VScrollBar

           

          override mx_internal function mouseWheelHandler(event:MouseEvent):void
                  {
                      const vp:IViewport = viewport;
                      if (event.isDefaultPrevented() || !vp || !vp.visible)
                          return;
                      
                      var delta:Number = event.delta;
                      var direction:Number = 0;
                      var distance:Number = 20;
                      
                      // figure out the direction of scroll
                      if (delta < 0){
                          direction = 1;
                      } else if (delta == 0){
                          direction = 0;
                      } else {
                          direction = -1;
                      }
                      
                      vp.verticalScrollPosition += distance * direction;
                      
                      event.preventDefault();
                  }
          

           

          and then applly these scrollbars in your ScrollerSkin

          • 2. Re: Scroller component speed
            Shongrunden Adobe Employee

            This should be easier in Flex 4.5: http://bugs.adobe.com/jira/browse/SDK-26432

            • 3. Re: Scroller component speed
              mattdwm Level 1

              I'm using Flash Builder 4.5, doesn't seem to be easier.