Help needed with Actionscript (continuous scroll)

wicky

play thing
I'm pretty new to actionscript, and I can't quite work out why this is only partially working. Can anybody help me?

This script is supposed to make a text box continuously scroll, as long as the button is pressed, "scrollUp" works OK, but "scrollDown" isn't doing anything.

(MX 2004)

SCRIPT ------------------------------------------


var srcollDirection:String;

// scroll buttons start

this.scrollDown.onPress = function() {
scrollDirection = "down";
scrollText();
}
this.scrollDown.onRelease = function() {
delete _root.onEnterFrame;
}
this.scrollDown.onReleaseOutside = function() {
delete _root.onEnterFrame;
}
this.scrollUp.onPress = function() {
scrollDirection = "up";
scrollText();
}
this.scrollUp.onRelease = function() {
delete _root.onEnterFrame;
}
this.scrollUp.onReleaseOutside = function() {
delete _root.onEnterFrame;
}
function scrollText () {
_root.onEnterFrame = function () {
if (srollDirection == "down") {
loadedText.scroll -= 1;
} else if (scrollDirection == "up") {
loadedText.scroll += 1;
}
}
}

// scroll buttons end

/ SCRIPT ------------------------------------------

Thanks in advance
 
wicky said:
}
function scrollText () {
_root.onEnterFrame = function () {
if (srollDirection == "down") {
loadedText.scroll -= 1;
} else if (scrollDirection == "up") {
loadedText.scroll += 1;
}
}
}

You misspelled "scroll."
 
oh dear.... what a muppet :eek:
(dyslexia~design)

Thanks. Do you know how to make this scroll at half the speed of the movie fps?
 
Unfortunately, I'm a C and Java programmer only... don't know much ActionScripting... :( I can't count how many times a large program has completely bombed on me because of one, little, miniscule little error like a typo -- it's common with every programmer!
 
I bet that drives you nuts!!

I'm fairly new to the whole scripting thing.... have you got any tips that I should now about when bug fixing, to avoid this kind of problem? I don't suppose a spell checker is much use with code?

Cheers
 
Hmmm... the one tip I can offer is that you can never look over parts of your code enough. It's almost instinct to go over your code, and skip over certain parts saying to yourself, "Yeah, yeah, I know that's working so the problem isn't there," but the problem is in the parts you overlook half of the time.

It's tough with an interpretive language like scripting since there's no compiling of the code -- you have to run the code to get any feedback about how it's working. There's no compiler there to alert you to syntactic errors or misspellings or anything.

I would just say take it slow, and chop it up into parts. You can create a fairly large and complex bit of code by dividing the code into littler pieces and tackling those one at a time... before you know it, you're done with the program.
 
Back
Top