Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically scroll to the end of a Flex Spark Textarea when a new line is added?

The old method for the mx:TextArea no longer works. Specifically:

myMxTextArea.verticalScrollPosition = myMxTextArea.maxVerticalScrollPosition;

I've found this method for Spark but seems a bit kludgy:

mySparkTA.scrollToRange(mySparkTA.text.length-1, mySparkTA.text.length);

Is there a more straightforward way to do this?

like image 779
Caqu Avatar asked Sep 06 '11 15:09

Caqu


3 Answers

Assuming that you have

<s:TextArea id="ta" width="100%" height="100%" />

The following will work:

ta.scroller.verticalScrollBar.value = ta.scroller.verticalScrollBar.maximum;

No need to wrap the TextArea in a Scroller component.

like image 137
jamix Avatar answered Oct 23 '22 23:10

jamix


That is how you do with with a spark textarea, but you could always try to wrap it in a Scroller component and not have the textarea itself bother with scrolling:

<s:Scroller id="scroller">
   <s:TextArea id="ta" width="100%" height="100%" />
</s:Scroller>

Then doing this in AS:

scroller.verticalScrollBar.value = scroller.verticalScrollBar.maximum;

There's no other easy way to do it.

like image 29
J_A_X Avatar answered Oct 24 '22 00:10

J_A_X


The spark TextArea has an "appendText" method This appends the text and scrolls automatically down to the line added..

like image 34
michaPau Avatar answered Oct 23 '22 22:10

michaPau