4 Replies Latest reply on Mar 30, 2011 11:02 AM by Yozef0

    Spark List Scrolling by Mouse Position

    Yozef0 Level 1

      I have a Spark List with the MouseOver event:

       

      protected function scroller_mouseOver(e:MouseEvent):void { 
         CursorManager.removeAllCursors();                    // Remove all previous Cursors
         if (mouseX > 24 && mouseX < 143) {
           if (mouseY > 220) {
                CursorManager.setCursor(downCursorSymbol);     // Down Cursor
           } else if (mouseY < 87) {
                CursorManager.setCursor(upCursorSymbol);     // Up Cursor
           }
           // Scroll as its Mouse Overed
           this.addEventListener(Event.ENTER_FRAME, scrollViaY);
           }
      }
      private function scrollViaY(e:Event):void {
         if (mouseX > 24 && mouseX < 143) { // location of mouse in the bottom (red) area
           if (mouseY > 220) {
           //trace('Down Hover - Pos previous: ' +  layout.verticalScrollPosition + '  Now: +' + (mouseY - 220));
           this.layout.verticalScrollPosition += (mouseY - 220)*0.5;     // Down hover || Scroll Up
           }
           else if (mouseY < 87) {     // location of the mouse in the top (red) area
           //trace('Up Hover - Pos previous: ' +  layout.verticalScrollPosition + '  Now: -' + (mouseY - 86));
           this.layout.verticalScrollPosition += (mouseY -86)*0.5;          // Up Hover || Scroll Down
           }
         }
      }
      

       

      List.png

       

      The Object, while it is over the Bottom Part of the List (in red), the lower it is the faster its suppose to scroll... yet there is a weird jittering effect going on.

       

       

      The desired effect is when the mouse is on the upper end (red), the higher the mouse is, the faster it scrolls up and the same with the bottom.