16 Replies Latest reply on Dec 16, 2006 7:41 AM by kglad

    pause a for loop

    MatMaar
      Hi

      I have a script where I duplicate a movieClip several times using the for loop statement.
      Now, between every duplication I want flash to wait for 1 second, befor duplicating the next one.

      Does anybody knows how tot do this?


      tx
      Tom
        • 1. Re: pause a for loop
          Sketchsta Level 1
          try this..

          setInterval(your duplicate function name, 1000, where to create);
          • 2. Re: pause a for loop
            kglad Adobe Community Professional & MVP
            you can't pause a for-loop.

            use a different kind of loop. sketchsta suggested a good choice except don't pass a "where to create" value.
            • 3. Re: pause a for loop
              Sketchsta Level 1
              hey kglad, since you're here now, could you tell me how to assign 2 functions to a onRelease action.

              a Late addition, to a website im doing, because of the set up i have, i need the onRelease to start 2 differen timelines playing.

              i have it working now, but im cheating as you can see...
              • 4. Re: pause a for loop
                Sketchsta Level 1
                P.S.
                sorry MatMaar, for posting a different question in your topic. =)
                • 5. Re: pause a for loop
                  kglad Adobe Community Professional & MVP
                  like so:



                  • 6. Re: pause a for loop
                    Sketchsta Level 1
                    You can call functions within functions??

                    That is soo kool...

                    I was looking into adding a listener:object then try to get it to do thing i want.
                    I didnt get verry far tho. =)

                    anyway, Thanx for that!
                    • 7. Re: pause a for loop
                      kglad Adobe Community Professional & MVP
                      yes, you can call functions within functions. even more cool is you can call the same function from within it. but be careful to not initiate an infinite loop.

                      you're welcome.
                      • 8. Re: pause a for loop
                        Sketchsta Level 1
                        quote:

                        Originally posted by: kglad
                        yes, you can call functions within functions. even more cool is you can call the same function from within it. but be careful to not initiate an infinite loop.


                        If I call the same function from within it's self, isn't that a Loop already?
                        how would you stop it from looping?
                        I know a function doesn't work until you call it, but is there a line of code that terminates a specific function?

                        but at the same time, I can't think of a reason why anyone would call the same function within it's self.
                        • 9. Re: pause a for loop
                          kglad Adobe Community Professional & MVP
                          calling functions from within them is extremely useful. i use that technique frequently. usually in setInterval() loops with variable rate of function call.

                          but here's code that's short and very useful. it will trace() the name of every movieclip in your swf.



                          • 10. Re: pause a for loop
                            Sketchsta Level 1
                            really?? give me some examples of when you would use this function from function technique...

                            You said you usually use this tech in setInterval() loops, that wouldnt stop the function looping from " the little " i know about AS.
                            but i remember seeing once something like
                            clearInterval()
                            would that do it? or does that just clear what has been done by the setInterval() prior to clearInterval().

                            maybe im just not seeing the " bigger picture " here.

                            Thats a kool piece of code there, it's abit out of my league tho. =)
                            Is there a way to trace() mouse pointer position, then save it to directory??
                            maybe even save it as .swf, or some kind of video file?

                            =P
                            • 11. Re: pause a for loop
                              Sketchsta Level 1
                              I MADE OVER 100 POSTS!!!!!!!!!!!!!!!!!!!

                              IM NOT A JUNIOR ANYMORE!!!!!!!!!!!!!!!!!!!!!

                              CELEBRATION!!!!!!!!!!!!!

                              =P
                              • 12. Re: pause a for loop
                                kglad Adobe Community Professional & MVP
                                the code i just gave in my previous message gave an example of a useful function calling itself repeatedly. just add that code to a fla that contains some nested movieclips and watch your output panel.

                                yes, i use clearInterval() followed by another setInterval() inside the function that setInterval call. by repeatedly changing the time parameter in setInterval() you can mimic various easing effects.
                                • 13. Re: pause a for loop
                                  Sketchsta Level 1
                                  quote:

                                  Originally posted by: kglad
                                  by repeatedly changing the time parameter in setInterval() you can mimic various easing effects.


                                  Thats where i've seen clearInterval() before, it was when i was practicing and experimanting with drawing API...
                                  i remember now.

                                  Yeah i noticed that in your previous code you were calling the same function from within, but this is just for a trace();
                                  I meant, to give me some ideas of when and how i could use it in making a website for example...
                                  anyway, it doesnt matter, this is the sort of stuff that I woun't forget. I'm sure i'll come across something that would require function from function method..

                                  (how do you like the name i came up with for your technique??)

                                  Now that you reminded me of drawing API, i just had a idea of how to make one of the websites i have.. I just have to learn how to call a tween function while drawing.. (if possible).. because if i have to manually animate it with AS it will take too long, and im not getting paid for this particular site.
                                  • 14. Re: pause a for loop
                                    kglad Adobe Community Professional & MVP
                                    function from function sounds good.

                                    but it's not my technique. it was used long before i found it.
                                    • 15. Re: pause a for loop
                                      Sketchsta Level 1
                                      well you're the one who told me about it, so to me... it's yours..

                                      if i ever use it to help someone on adobe.com, i'll say...
                                      "All thanx goes to KinGLAD"
                                      =P
                                      • 16. Re: pause a for loop
                                        kglad Adobe Community Professional & MVP
                                        thanks. :)