如何以编程方式滚动到mx的底部:Flex中的TextArea?

kno*_*orv 2 apache-flex

考虑以下mx:TextArea ..

<mx:TextArea id="textArea"/>
Run Code Online (Sandbox Code Playgroud)

..使用..定期更新新的文本行

textArea.text += newLineBeingAdded + "\n";
Run Code Online (Sandbox Code Playgroud)

..如何确保textarea向下滚动到底部,以便添加的最后一行对用户可见?

Sam*_*eff 5

添加文本集后

callLater(scrollToEnd);

....

function scrollToEnd():void {
   textArea.verticalScrollPosition = int.MAX_VALUE;
}
Run Code Online (Sandbox Code Playgroud)

它应该滚动到最后.

甚至比callLater更好的是使用invalidateProperties/ commitProperties.