3 Replies Latest reply on Jan 9, 2009 10:01 AM by Almudever

    Scrolling text with keyboard

    Almudever
      I want to scroll the text up and down with the keyboard. With the arrow keys up and down.

      How is it possible?

      Thanks
        • 1. Re: Scrolling text with keyboard
          Level 7
          You must detect key strokes using one of several methods. I use an
          exitFrame handler with a case statement and keyCodes:

          on exitFrame me
          case (the keyCode) of
          13: -- Carriage return
          -- code here when CR is hit
          46: -- this is some ascii code for a alpha char
          -- code here when that alpha char is hit
          end case
          end

          of course you would use the keyCodes from the arrow keys. You can get them
          by putting "the keyCode" (without quotes) into the object inspector then
          hitting the up and down arrow keys separately and noting the value of the
          keyCode. A director movie must be running and the stage must have focus
          for the values to be captured. Or you could use "put the keyCode" in an
          exitFrame handler and check the message window for the numbers. Of course
          the message window will fill up pretty fast so I recommend the first method.

          Then, within the cases for up and down arrows you use the scrollLine and/or
          scrollPage methods to move the text in the field/text member up or down.
          This is a simplified answer because correct coding always requires checks
          and monitoring that I haven't listed here. It's not critical but makes for
          cleaner code and operation.

          Craig


          --
          "Almudever" <webforumsuser@macromedia.com> wrote in message
          news:gk2a72$nfa$1@forums.macromedia.com...
          >I want to scroll the text up and down with the keyboard. With the arrow
          >keys up and down.
          >
          > How is it possible?
          >
          > Thanks


          • 2. Re: Scrolling text with keyboard
            James Newton, ACP Level 3
            You can find demo and source for a custom scroll bar here. This includes a ScrollByArrows behavior, attached to the lower of the two scrolling sprites. You could use this as a starting point for a behavior of your own.