0 Replies Latest reply: Jul 16, 2014 10:48 PM by $h@!k101 RSS

    Customizing a VScrollBar is not working in Flex sdk 4.6?

    $h@!k101

      Hi,

       

      I have updated my Flex sdk from 4.5 to 4.6 in my application. I have faced a strange issue this sdk 4.6.

       

      In my application I have designed a Custom VScrollbar for customizing the vertical scroll speed of a mouse wheel to smooth-en the scrolling . This was working fine when using Flex sdk 4.5.

       

      Since I have updated to Flex sdk 4.6, the vertical scroll bar in not visible in UI. Whereas it was visible and working fine using Flex sdk 4.5.

       

      How to make it work in Flex sdk 4.6?

       

      The usage of the Customized Scroller is given below.

       

      In Main Page:

      <components:CustomScroller id="homeUIScroller"

                                     width="100%" height="100%">

             

              <s:VGroup >

                          ......................

              </s:VGroup>

       

      </components:CustomScroller>

       

       

      CustomScroller.as:


      public class CustomScroller extends Scroller

          {

              public function CustomScroller()

              {

                  super();

                  this.verticalScrollBar = new CustomVScrollBar();

              }

         }

       

      CustomVScrollBar.as

          import flash.events.MouseEvent;

         

          import mx.core.mx_internal;

          import mx.events.FlexEvent;

         

          import spark.components.VScrollBar;

          import spark.core.IViewport;

         

          use namespace mx_internal;

         

          public class CustomVScrollBar extends VScrollBar

          {

             

              private var distance:Number = 78;    // default scroll mover value

             

             

              /**

               *  Override mouseWheelHandler to scroll by a fixed amount

               *  See superclass for example of how this normally works

               */

              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;

                 

                  if (delta < 0){

                      direction = 1;

                  } else if (delta == 0){

                      direction = 0;

                  } else {

                      direction = -1;

                  }

                 

                  if(direction == -1 && vp.verticalScrollPosition <= 0)

                      return;

                 

                  if(direction == 1 && (vp.verticalScrollPosition + distance) > maximum)

                      return;

                 

                  vp.verticalScrollPosition += distance * direction;

                  event.preventDefault();

              }

      }

       

       

      Any help would be appreciated.

       

      Thanks In advance.