all groups > flash (macromedia) > october 2007 >
You're in the

flash (macromedia)

group:

looping


looping PAI_T-Bone
10/10/2007 8:35:36 PM
flash (macromedia):
Hello,
I'm trying to get a counting loop working. well i don't really know if
its a counting loop. What is supposed to happen is this code
stop();
selectModuleCounter = 0;

if (selectModuleCounter>15) {
gotoAndStop(1);
} else {
selectModuleCounter++;
}
is supposed to keep adding till selectModuleCounter is greater than 15,
then goto frame 1. As is now it just counts once, 1, then stops. How can i get
it to keep counting till 15, or more, is reached ? I tried using a FOR loop but
it goes way to quickly. I'm using AS2 by the way.

Thanks for any help you can offer up.

any thoughts on how i can get this to work ?
Re: looping dzedward
10/10/2007 8:49:52 PM
stop();

var selectModuleCounter:Number = 0;

var myInt = setInterval(countIt, 1000); // 1000 = 1 second
function countIt(){
if(selectModuleCounter > 15){
gotoAndStop(1);
clearInterval(myInt);
} else {
selectModuleCounter++
}
}
Re: looping dzedward
10/10/2007 8:53:27 PM
so every second your variable increases by 1

Re: looping PAI_T-Bone
10/10/2007 9:11:36 PM
thanks for the help.

Re: looping dzedward
10/10/2007 9:16:23 PM
Your attempt worked, only it worked once as it entered the frame it was on. I
set up an interval to run every 1 second, and every time the interval fires it,
first, checks to see what the value of the variable is, and if it doesnt meet
the requirement, it will increase it by 1, if it does meet the requirement, it
will go to frame 1 and stop the interval. (ps: very important to clear an
interval when not needed)


Re: looping PAI_T-Bone
10/10/2007 9:48:03 PM
Re: looping dzedward
10/10/2007 10:09:47 PM
Re: looping PAI_T-Bone
10/10/2007 10:23:21 PM
Re: looping dzedward
10/10/2007 10:31:35 PM
Re: looping Mel81x
10/11/2007 12:00:00 AM
Re: looping dzedward
10/11/2007 2:20:01 PM
The function is not a loop, it is an interval. Once the playhead reaches the frame it resides on, it will start to execute that function every second until the clearInterval() is called.

AddThis Social Bookmark Button