Below is the code to autoscroll your mouse cursor to the bottom of the TextArea.
import fl.controls.TextArea;
import flash.utils.setTimeout;
var outputTA : TextArea;
createTextArea(50, 50, 100, 100);
showMessage("How to auto scroll to bottom page in a textfield:\n");
showMessage("this is top!");
showMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
showMessage("this is bottom!");
/**
 * Creates the text area.
 */
function createTextArea(x:Number, y:Number, width:Number, height:Number) : void
{
    outputTA = new TextArea();
    outputTA.setSize(width, height); 
    outputTA.move(x, y);
    addChild(outputTA);
}
/**
 * Display message to text area
 */
function showMessage(message:String):void
{
    outputTA.text += message + "\n";
    autoscroll();
}
/**
 * Automatically scroll to the bottom of the textarea
 */
function autoscroll():void
{
    setTimeout(function():void{outputTA.verticalScrollPosition = outputTA.maxVerticalScrollPosition;},100);
}

 
No comments:
Post a Comment