# Looping

**URL:** <https://forum.kirupa.com/t/looping/27085>\
**Category:** Uncategorized\
**Created:** [July 30, 2003, 1:25am UTC](https://forum.kirupa.com/t/looping/27085 "2003-07-30T01:25:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ah\_yi](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@ah\_yi](https://forum.kirupa.com/u/ah_yi)\
**Post date:** [July 30, 2003, 1:25am UTC](https://forum.kirupa.com/t/looping/27085/1 "2003-07-30T01:25:02Z")

</div>

how can i actually loop for example frame 10 to frame 50 for a certain number of times after i press a button? i tried using this actionscript but it can actually loop for one time.

on (release) {  
gotoAndPlay(46);  
for (i=1; i\<4; i++) {  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2003, 1:27am UTC](https://forum.kirupa.com/t/looping/27085/2 "2003-07-30T01:27:06Z")

</div>

on your button  
[AS]  
on(release){  
gotoAndPlay(10);  
i=1;  
}  
[/AS]  
on frame ten  
[AS]  
i++;  
[/AS]  
on frame fifty  
[AS]  
//just say your certain number of times is ten  
if (i==11){  
stop();  
}  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2003, 2:54am UTC](https://forum.kirupa.com/t/looping/27085/3 "2003-07-30T02:54:02Z")

</div>

hi freddythunder, i had tried putting in the actionscript but for instance if i want to loop the frames for 10 times i need to write:

gotoAndPlay(46);  
if (i==10){  
stop();  
}

but the problem is that on the first time i press on the button it will loop for 10 times but after the first press the number of loop will be increase by one. And in your actionscript there’s no:

gotoAndPlay(46);

i had tried not putting that in but the problem is that it will not loop at all.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2003, 10:22am UTC](https://forum.kirupa.com/t/looping/27085/4 "2003-07-30T10:22:51Z")

</div>

Try this:[AS]on(release){  
gotoAndPlay(10);  
i=1;  
}[/AS]on frame 50:  
[AS]if (i==10) {  
// Do whatever you like  
}  
else {  
i++ ;  
gotoAndPlay (10) ;  
}[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2003, 1:44pm UTC](https://forum.kirupa.com/t/looping/27085/5 "2003-07-30T13:44:16Z")

</div>

> loop for example frame 10 to frame 50 for a certain number of times

> i need to write:  
> gotoAndPlay(46);

I used the example 10 to 50, the certain number of times was 10; where would I get 46 from? And yes, mine should be (i==10)\_ - _typo, sorry…_

Ilias’ does the same thing - so whichever works for ya!!(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 31, 2003, 2:14am UTC](https://forum.kirupa.com/t/looping/27085/6 "2003-07-31T02:14:15Z")

</div>

i already tried the latest actionscript that you all had sent me but the problem is that when i press the button the led will not run at all.  
i had already attact the previous file. the problem for it is that when SW3 is pressed for the first time, the led will loop for 3 times but after the first pressing, everytime when press it will loop for 4 times.  
i already attach the file hope that you can help. thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 31, 2003, 2:56am UTC](https://forum.kirupa.com/t/looping/27085/7 "2003-07-31T02:56:54Z")

</div>

On frame 44, you have a gotoAndPlay(2); action so, the way it’s set up, when you hit the play button, it will loop frames 1-44 forever. It will never reach anything past frame 44. What did you want to do?

There seems to be two seperate things you want to accomplish. The first one where the leds blink from the top to bottom. Then another one (past frame 44) that blinks just the top four. Could you describe what you want done with it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 31, 2003, 5:39am UTC](https://forum.kirupa.com/t/looping/27085/8 "2003-07-31T05:39:58Z")

</div>

so sorry that i don’t know that i had added in an extra script on frame 44.

when the play button is being press, the led will run from the top to the bottom repeatingly. only when i pressed the SW3, then the first four led to run turn by turn and loop for three times.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 1, 2003, 4:48am UTC](https://forum.kirupa.com/t/looping/27085/9 "2003-08-01T04:48:13Z")

</div>

That’s what it is doing for me already. Is there something I’m missing?
