Skip navigation
Currently Being Moderated

How to auto-scroll a Spark TextArea when adding text ?

Mar 4, 2011 5:50 AM

Hi all,


I'm looking for the best method to auto-scroll my Spark TextArea to the bottom when I add text in it.

I'm adding text using textFlow.addChild() and I listen the CompositionCompleteEvent.COMPOSITION_COMPLETE event on the textFlow component in order to set the vertical scrollbar value to its maximum.


But sometimes, it doesn't work very well... Maybe I'm not using the proper event, on the appropriate object... That's why I'm asking for your help ^^


Thanks you in advance !

  • Currently Being Moderated
    Mar 25, 2011 12:35 PM   in reply to KnuX75002

    It really is lonely when nobody answers your questions. lol


    Unfortunately, I have no answers for you because I'm a newbie. But let me ask you something. Say I have a box with news items (text) and I want it to scroll continuously, would you know how to accomplish that?

    Mark as:
  • Currently Being Moderated
    Mar 25, 2011 1:22 PM   in reply to DS8108

    I'm just shooting in the dark here but maybe you could listen for the TextOperationEvent and force the text area to scroll to the bottom?

    Mark as:
  • Currently Being Moderated
    Mar 6, 2013 11:52 AM   in reply to KnuX75002

    Use textArea.appendtext() method

    will scroll down atuomatically

    Mark as:
  • Currently Being Moderated
    Mar 7, 2013 6:13 AM   in reply to KnuX75002

    Here is my old blog post about auto scrolling a text area.  And here is the updated blog post with View Source.


    Here's the basic code.  It does have limitations.

    <s:TextArea id="fooText" width="200" height="200"
    valueCommit="fooText.scroller.verticalScrollBar.value = fooText.scroller.verticalScrollBar.maximum" />


    You will notice in my updated example, setting the verticalScrollPolicy to "auto", does not move the TextArea up.


    Message was edited by: DeanLoganBH  - added link to updated blog post and view source

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points