让TextArea的垂直滚动条总是滚到对下面,即总是显示最新的信息,比如聊天。
写个类继承自TextArea,重写几个方法可以做到:
/** * 聊天用,内容更新时verticalScrlooBar自动调整到最后一行 * 关掉面板重新打开会有些误差 */ override public function set htmlText(value:String):void { super.htmlText = value; this.validateNow(); if(textField) verticalScrollPosition = textField.maxScrollV; } override public function set text(value:String):void { super.htmlText = value; this.validateNow(); if(textField) verticalScrollPosition = textField.maxScrollV; }