<mx:Script>
<![CDATA[
this.textarea.addEventListener(FlexEvent.VALUE_COMMIT,onValueCommit);
private function onValueCommit(event:FlexEvent):void{
this.textarea.verticalScrollPosition=this.textarea.maxVerticalScrollPosition;
}
]]>
</mx:Script>
<mx:TextArea left="2" right="2" top="2" bottom="28" fontSize="12" editable="false" id="textarea">
<mx:htmlText>
<![CDATA[<b><font color='#FF0000'>Welcome to Flexchat!</font></b>]]>
</mx:htmlText>
</mx:TextArea>
<![CDATA[
this.textarea.addEventListener(FlexEvent.VALUE_COMMIT,onValueCommit);
private function onValueCommit(event:FlexEvent):void{
this.textarea.verticalScrollPosition=this.textarea.maxVerticalScrollPosition;
}
]]>
</mx:Script>
<mx:TextArea left="2" right="2" top="2" bottom="28" fontSize="12" editable="false" id="textarea">
<mx:htmlText>
<![CDATA[<b><font color='#FF0000'>Welcome to Flexchat!</font></b>]]>
</mx:htmlText>
</mx:TextArea>
如上,当有新的内容加入到textarea时,它的滚动条就会自动滚动到最底部,你可以在某一个方法中不停地往textarea里面追加内容。如:
this.textarea.htmlText=this.textarea.htmlText+"<br>"+msg;
这里的TextArea是Flex3中的mx:TextArea