Link to home
Start Free TrialLog in
Avatar of yahoolane
yahoolane

asked on

flex 4 textarea always show bottom

IN Flex 4

I add and add texts,
 
I want to always show the last text
so the text box will need to be scrolled to the bottom.



Avatar of dgofman
dgofman
Flag of United States of America image

why you cannot try something like this

textArea.text =  label.text + NEXT_STR;
textArea.scrollPosition = textArea.maxScrollPosition;
Enter text into TextField and press ENTER

private function onChange(event:Event):void{
      txtArea.text += txtInput.text + "\n";
      txtArea.verticalScrollPosition = txtArea.maxVerticalScrollPosition;
     txtInput.text = "";
}
      <mx:TextInput id="txtInput" enter="onChange(event)"/>
      <mx:TextArea id="txtArea"/>
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yahoolane
yahoolane

ASKER

No Joy

1119: Access of possibly undefined property maxScrollPosition through a reference with static type spark.components:TextArea

1119: Access of possibly undefined property scrollPosition through a reference with static type spark.components:TextArea.

Remember I am using Flex 4
.      
In this case you just need to use scrollToRange function

private function onChange(event:Event):void{
    txtArea.text += txtInput.text + "\n";
    txtArea.scrollToRange(int.MAX_VALUE);
    txtInput.text = "";
}
      <s:TextInput id="txtInput" enter="onChange(event)"/>
      <s:TextArea id="txtArea" height="100"/>
Hi yahoolane,
Please can you accept my answer.
I gave you two solutions for SDK 3 and 4.
Thanks,
David