Question
Continuous Scrolling Text using buttons, HELP!
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?
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?