-
AS2. while loop, setInterval, clearInterval problem
I'm trying to get my code working so effectively the playhead moves backwards for a certain length of time (20 frames, 1 frame every 33 milliseconds). The setInterval function works when not inside the WHILE but I need it to run 20 times and then use the clearInterval function to stop it. I can't seem to figure out how to solve it. Currently it outputs 1 through to 20 and then "clear interval". Can someone please give me a hand? here is the code which is inside an onRelease button holder. Thanks to anyone with input.
var myInterval = setInterval(slow, 33);
var counter = 0
while (counter < 20) {
counter++;
trace(counter);
function slow (){
trace("slow function");
prevFrame();
}
}
clearInterval(myInterval);
trace("clear interval");
-
Code:
on (release) {
clearInterval(myInterval);
var myInterval = setInterval(slow, 33);
var counter = 0;
function slow() {
if (counter<20) {
counter++;
trace(counter);
trace("slow function");
prevFrame();
} else {
clearInterval(myInterval);
trace("clear interval");
}
}
}
-
Webpages:
www.winningsolutionsinc.com
-
Beautiful, thanks so much.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|