7 Replies Latest reply on Nov 19, 2009 1:06 PM by Jerry62712

    How do I trap a mouse event?

    Jerry62712 Level 1

      I am trapping keyboard events with AutoScroll12.as, but find it is also killing the mouse.  That is, if you want to use the mouse to scroll down such that the object with the current focus would be forced off the page, you can't do it.

       

      What I expect I need is an ability to trap mouse events within that script and just bail out of it in those cases.  Thus, if you use the mouse to scroll (roller, clicking below or above the thumb or dragging the thumb), the script would be ignored.

       

      I was thinking of inserting an "if" to return and let the event bubble to the OS.  But I don't know how to trap mouse events.

       

      public class AutoScroll12 {
              public static function autoScroll12(event : Event) : void {
                  var container : Container = Container(event.currentTarget);
                  var focusItem : DisplayObject = DisplayObject(container.focusManager.getFocus());

      psuedo-code here:

                  if (event.type == MouseEvent.CLICK)
                      return;

       

                  if(container.verticalScrollBar && focusItem) {
                      if( focusItem == container || !container.contains(focusItem) ) {
                          return;
                      }

       

                      var focusTopEdge : int = focusItem.y;
                      var thisItem : DisplayObjectContainer = focusItem.parent;

       

      How would I do this?