20 September, 2008

Flex - autoscrolable text area

Need TextArea with automatic scrolling to bottom?
This is not trivial, but simple:


emc\components\AutoScrollableTextArea.as
package emc.components {
import mx.controls.TextArea;

public class AutoScrollableTextArea extends TextArea {
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
verticalScrollPosition = textField.numLines;
}
}
}

For example, it is useful for outputting log information.

No comments: