3 Replies Latest reply on Oct 2, 2006 4:30 PM by Mister Peanut

    onMouseWheel

    Mister Peanut Level 1
      hello, I am trying to scroll text within a text field named theText. with this code, the entire text container scrolls upward out of theText field. How do I just get the text to scroll within the container? This is the AS I am using:

      var mouseListener:Object = new Object();
      mouseListener.onMouseWheel = function(delta) {
      theText._y += delta;
      }
      Mouse.addListener(mouseListener);

      Thanks for any help!
        • 1. Re: onMouseWheel
          Mister Peanut Level 1
          I have found code that works:

          //this scrolls the text with the mouse wheel!!!
          theText.text = "l1\nl2\nl3\nl4\nl5\nl6\nl7\nl8";
          var mouseListener = new Object();
          mouseListener.onMouseWheel = function(steps) {
          theText.scroll -= steps;
          }

          HOWEVER, whenever I hit a button, scroll down to the bottom of the text, exit, and then hit another button that loads text into the same field, the scrollbar starts at the bottom of the newly loaded text. How can I reset the scrollbar each time I exit?
          • 2. Re: onMouseWheel
            Rothrock Level 5
            Now that is how to bump a thread!

            Check out the TextField.scroll property. It is the number of lines from the top that a give text field is scrolled. My guess would be to set it back to zero (or whatever value it had at the start.)

            PS: I don't think the Mac version of the Flash player/plug-in supports scroll wheels. So if that is part of your audience you might want to provide other means of scrolling the text.
            • 3. Re: onMouseWheel
              Mister Peanut Level 1
              Here's what I needed:

              theText.scroll =0;

              simple, I know....

              Thanks again, Rothrock. I have scrollbars as well. I just wanted to add more usability.

              P