1 Reply Latest reply on Nov 21, 2010 6:23 AM by kglad

    Repeat function after x seconds?

    antworker Level 1

      Hello,
      I just wonder if I could make the object "car" to repeat doing this:

       

      function start_car(){
          _root.car.onEnterFrame = function(){
              _root.car._y +=15;
          };
      };

       

      setTimeout(start_car, 1000);

       

      I want it to begin at y=0 and x=0 after like 7 seconds and then repeat going down the y axis as you can see in the code.

       

      So the car movieclip starts moving slowly from the top going down then  after like 7 seconds when it's out of the scene it begins at e.g x=0 y=0  and going down for 7 seconds then starts at x=0 y=0.... etc, so it  keeps looping.

       

       

      What I got so far is that the car waits 1 seconds then moving down...

       

       

      Hope you understand my problem

       

      Thank you!

        • 1. Re: Repeat function after x seconds?
          kglad Adobe Community Professional & MVP

          you should mark your previous thread as answered.

           

          :

           


          function start_car(){

          _root.car._y=0
               _root.car.onEnterFrame = function(){         _root.car._y +=15; if(_root.car._y>Stage.height){
          delete this.onEnterFrame;
          }

              }; };

           

          setInterval(start_car, 7000);