3 Replies Latest reply on Dec 16, 2008 7:06 PM by AlexAAM

    mouse wheel scroll question

      Hello to all, i want to make the following question:
      I have a canvas which has a vertical scroll bar, inside this canvas there is a textarea control which has a vertical scroll bar too. That i want to make is:
      when the user put the mouse cursor on to the textarea and use the mouse wheel i want to make scrolling the canvas and not the textarea.

      any help will be appreciated.
      thanks in advance
        • 1. Re: mouse wheel scroll question
          -Hob Level 1
          You'll probably need to extend TextArea to get this to work and override protected function mouseWheelHandler(). TextArea does an event.stopPropagation() in its version of this function. If you override the function and simply do nothing (do NOT call super.mouseWheelHandler()), that might do the trick.
          • 2. Re: mouse wheel scroll question
            rtalton Level 4
            You could try this:
            1) Set textArea mouseChildren="false".
            2) Add an eventListener to to the TextArea for its mouse wheel event when the app loads.
            3) In the listener, scroll the canvas component.
            See attached code for a working example. Just be aware that if you do this, users will NOT be able to scroll the textArea at all.
            • 3. Re: mouse wheel scroll question
              AlexAAM Level 1
              Thanks for the replies. The solution to my question is this:

              import flash.events.MouseEvent;

              import mx.controls.TextArea;

              public class newTextArea extends TextArea
              public function newTextArea()

              override protected function createChildren():void
              textField.mouseWheelEnabled = false;

              private var scrollAnterior:Number=-1;
              private var direccionScroll:Number=0;
              override protected function mouseWheelHandler(event:MouseEvent):void

              var dirScroll:int = event.delta <= 0 ? 1 : -1;
              if (verticalScrollPosition==scrollAnterior && direccionScroll==dirScroll)


              it works fine, but now i want to make the same with the canvas, but seems is not possible override mouseWheelHandler event in it. Any help or suggestion ?

              Thanks in advance