Hi,
So I have created a scrollbar for a dynamic textField by using the following code:
scrollBar = new UIScrollBar();
scrollBar.scrollTarget = lobbyChat.incoming_txt;
scrollBar.height = lobbyChat.incoming_txt.height;
//Move the scrollbar to the righthand side
scrollBar.move(lobbyChat.incoming_txt.x+lcx + lobbyChat.incoming_txt.width, lobbyChat.incoming_txt.y+lcy);
//add it to the stage
addChild(scrollBar);
}
public function updateText():void{
scrollBar.update();
if (scrollBar.enabled == false) {
scrollBar.alpha = 0;
} else {
scrollBar.alpha = 100;
}
}
Works good, but only one issue. Every time it updates, the scrollbar needs to scroll down with the text. Imagine a simple chat room, where every time you press enter your text is shot off, received on the other end and added to the dynamic textField. The scrollbar, however, does not move unless you actually click it and scroll down. So using this code I could write “Hello” 50 times, but unless I actually click the scrollbar and hold it with my mouse, and move it down, I won’t see the other messages. It basically stays on the top unless I scroll down, just like a web page scrollbar, like the one on this webpage.
I did have a fix for this a long time ago, but it was not clean code so I don’t want to go with it. Any simple fix?
tyty:proud: