http://flexponential.com/samples/ScrollToBottom/srcview/
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
viewSourceURL="srcview/index.html">
<fx:Script>
<![CDATA[
import spark.core.NavigationUnit;
private function addMessage():void {
// add the message
chatList.dataProvider.addItem({label:message.text});
// clear the text input
message.text = "";
// scroll to the bottom of the List to show this item
scrollToBottom();
}
private function scrollToBottom():void {
// update the verticalScrollPosition to the end of the List
// virtual layout may require us to validate a few times
var delta:Number = 0;
var count:int = 0;
while (count++ < 10){
chatList.validateNow();
delta = chatList.layout.getVerticalScrollPositionDelta(NavigationUnit.END);
chatList.layout.verticalScrollPosition += delta;
if (delta == 0)
break;
}
}
]]>
</fx:Script>
<s:Panel title="Chat" defaultButton="{btn}" horizontalCenter="0" verticalCenter="0" width="300">
<s:List id="chatList" alternatingItemColors="[#EEEEEE,#DDDDDD]" height="120" width="100%">
<s:layout>
<s:VerticalLayout horizontalAlign="justify" gap="0" />
</s:layout>
<s:dataProvider>
<s:ArrayCollection id="dp" />
</s:dataProvider>
</s:List>
<s:controlBarContent>
<s:TextInput id="message" width="100%" />
<s:Button id="btn" label="Send" click="addMessage()" />
</s:controlBarContent>
</s:Panel>
</s:Application>