Scroll automatically to the bottom of spark TextArea

转载:http://www.smithfox.com/?e=172

 

[备忘] Scroll automatically to the bottom of spark TextArea

Use appendText function, spark TextArea will automatically scroll to bottom.

If you use TextArea.textFlow.addChild(xx), you should add some code:

1. write a function:

private function textAreaScrollToBottom(event:Event):void {
trace("textAreaScrollToBottom");
textArea.scroller.verticalScrollBar.value = textArea.scroller.verticalScrollBar.maxHeight;
//textArea.scroller.verticalScrollBar.validateNow();
}

2. listen TextArea.updateComplete event, and invoke textAreaScrollToBottom()

3. listen TextArean.textFlow.updateComplete event, and invoke  textAreaScrollToBottom()

Yes, you must listen both TextArea.updateComplete and TextArean.textFlow.updateComplete!!

 

你可能感兴趣的:(Scroll automatically to the bottom of spark TextArea)