<s:TextArea id="consoleTextArea" change="consoleTextArea_changeHandler(event)" valueCommit="consoleTextArea_valueCommitHandler(event)" updateComplete="scrollToTheBottom()" />
And then in ActionScript:
protected function consoleTextArea_valueCommitHandler(event:FlexEvent):void { scrollToTheBottom(); } protected function consoleTextArea_changeHandler(event:TextOperationEvent):void { scrollToTheBottom() } public function scrollToTheBottom():void { var scrollBar:VScrollBar = consoleTextArea.scroller.verticalScrollBar; scrollBar.value = scrollBar.maximum; consoleTextArea.validateNow(); if (scrollBar.value != scrollBar.maximum) { scrollBar.value = scrollBar.maximum; consoleTextArea.validateNow(); } }
You may need to put the if statement in a loop for several iterations or until the value matches or is close to the maximum.
Update : Added a listener for the updateComplete event. This may prevent someone from typing, but may work fine for this use case.
source share