Skip to main content
March 4, 2009
Question

Continuous Scrolling Text using buttons, HELP!

  • March 4, 2009
  • 3 replies
  • 673 views
Hello all...

I am trying to create a very simple scrolling text box. The idea is for the text to scroll upon pressing and holding down the mouse button on the up or down arrow.

This is what I have so far, it scrolls, but it doesn't stop, and it keeps getting stuck, and doing a "twitching" kinda thing. Here is my code....

var intervalNum:Number;
down_btn.onPress = function() {
textField_txt.scroll += 1;
intervalNum = setInterval(scrollFunc, 52, "down");
};
down_btn.onMouseUp = function(){
clearInterval(intervalNum);
};
up_btn.onPress = function() {
textField_txt.scroll -= 1;
intervalNum = setInterval(scrollFunc, 52, "up");
};
up_btn.onMouseUp = function(){
clearInterval(intervalNum);
};
function scrollFunc(direction:String){
if (direction == "down"){
textField_txt.scroll += 1;
} else if (direction == "up") {
textField_txt.scroll -= 1;
}
};

Can anyone help, what am I doing wrong?
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
March 5, 2009
actually, you don't need to put limits on the scroll property. flash does that for you.

the only problem you might have with that is if the mouseup occurs while the mouse is not over your stage. (and you don't need two onMouseUp() methods.)
March 5, 2009
Thanks for your help kglad...I am really new to AS, so...I don't really know exactly what you are referring to. If you get a chance, could you clarify a little. Thanks a ton!
kglad
Community Expert
Community Expert
March 5, 2009
don't allow your scroll property to exceed the maxscroll property of your textfield or be less than 0.