Groups | Blog | Home
all groups > flash actionscript > november 2004 >

flash actionscript : Repeating code on button


teddy0bear
11/4/2004 11:27:15 PM
I am making a little fake scroller that will scroll a movie clip up and down. I
have it set up so if you hit the up button 20 is added to the _y variable and
the opposite for the down button. This works! and i'm happy. However, i want it
to work so if you hold down the buttons it will continually add 20 to _y until
u either move the mouse off or it reaches a certain point (i used an if
statment to constrain how far the movie clip is allowed to move). I tried a
while loop but it doesn't work (for some reason) and i'm looking for another
way. Any idea?
_jrh_
11/4/2004 11:52:48 PM
Use setInterval to call the function that scrolls your clip, such as:

// on the scroll up button
on (press) {
scrollID = setInterval(scrollUp,50);
}

Where scrollUp is the function that decreases the _y value.
_jrh_
11/4/2004 11:56:12 PM
I forgot, you'll also need:

on (release) {
clearInterval(scrollID);
}
// and
on (releaseOutside) {
clearInterval(scrollID);
AddThis Social Bookmark Button