Skip to main content
pao1011
Known Participant
April 29, 2009
Question

textArea vPosition

  • April 29, 2009
  • 1 reply
  • 1156 views

I have a chat in which when the text area is full and start the scrollbar, the scrolling always go to the top and I want to go to the bottom. I try to use the vPosition  but i get errors. This is basically what I want to get.

var my_ta:mx.controls.TextArea;
my_ta.vPosition = my_ta.maxVPosition;

If anybody have any ideas or can help me witll be grately appreciated.

Thanks in advance.

Pao

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 30, 2009

use verticalScrollPosition and maxVerticalScrollPosition

pao1011
pao1011Author
Known Participant
April 30, 2009

This is a code in a chat with AS 1.0 which works fine

users_so.msgFromSrvr = function(msg) {

  _root.History.text += msg;
  _root.History.scroll = _root.History.maxscroll;
  historyScroll.setScrollTarget(history);
  historyScroll.setScrollPosition(_root.History.maxscroll);

};

This is the one I comeup i AS 3.0 but it does nothing


function msgFromSrvr(msg:String):void
{
History.appendText(msg);
function scrollHandler(event:ScrollEvent):void {
    var History:TextArea = event.currentTarget as TextArea;
    var pos:Number = event.position;
    var maxPos:Number;

if (event.direction == ScrollBarDirection.VERTICAL) {
        maxPos = History.maxVerticalScrollPosition;

}

       }
}

I do not get error but not work I'm not an AS coder or something similar. I'm only work with the Help files or I look at tutorials that have similar codes,.Hope not think I want someone write the code for me just to leanr how to do it.

kglad
Community Expert
Community Expert
April 30, 2009

pao1011 wrote:

This is a code in a chat with AS 1.0 which works fine

users_so.msgFromSrvr = function(msg) {

  _root.History.text += msg;
  _root.History.scroll = _root.History.maxscroll;
  historyScroll.setScrollTarget(history);
  historyScroll.setScrollPosition(_root.History.maxscroll);

};

This is the one I comeup i AS 3.0 but it does nothing


function msgFromSrvr(msg:String):void
{
History.appendText(msg);
function scrollHandler(event:ScrollEvent):void {
    var History:TextArea = event.currentTarget as TextArea;
    var pos:Number = event.position;
    var maxPos:Number;

if (event.direction == ScrollBarDirection.VERTICAL) {
        history.verticalScrollPosition = History.maxVerticalScrollPosition;  // if this is when you want to scroll to the last line

}

       }
}

I do not get error but not work I'm not an AS coder or something similar. I'm only work with the Help files or I look at tutorials that have similar codes,.Hope not think I want someone write the code for me just to leanr how to do it.