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.
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.
Enter text into TextField and press ENTER
private function onChange(event:Event):void {
txtArea.text += txtInput.text + "\n";
txtArea.verticalScrollPosi tion = txtArea.maxVerticalScrollP osition;
txtInput.text = "";
}
<mx:TextInput id="txtInput" enter="onChange(event)"/>
<mx:TextArea id="txtArea"/>
private function onChange(event:Event):void
txtArea.text += txtInput.text + "\n";
txtArea.verticalScrollPosi
txtInput.text = "";
}
<mx:TextInput id="txtInput" enter="onChange(event)"/>
<mx:TextArea id="txtArea"/>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
.
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"/>
private function onChange(event:Event):void
txtArea.text += txtInput.text + "\n";
txtArea.scrollToRange(int.
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
Please can you accept my answer.
I gave you two solutions for SDK 3 and 4.
Thanks,
David
textArea.text = label.text + NEXT_STR;
textArea.scrollPosition = textArea.maxScrollPosition