5 Replies Latest reply on Feb 18, 2009 1:08 PM by

    setting up my website on a 5 second timer

      Hello I was wondering how you can get your flash file to time every 5 seconds to do a function (like gotoAndPlay (5)).

      The thing with this code is it doesn't stop the timer after the transition so i get this endless loop where it goes back to frame 5 I would like to be able to turn this timer off after it fires so that when it is on frame 5 it then goes to frame 10 after the next 5 seconds.

      I wouldn't mind just using this code somehow because it seems easy. Thanks so much!
        • 1. Re: setting up my website on a 5 second timer
          Ned Murphy Adobe Community Professional & MVP
          The way you have it set up, the Timer will fire forever, which is probably what you want anyways based on your description. So what you need to do is increment the value of the gotoAndPlay(#) frame number each time the handler is called

          var frameNum = 2;

          function handleTimer(event:TimerEvent):void
          {
          gotoAndPlay( frameNum );

          frameNum += 5;
          }
          • 2. Re: setting up my website on a 5 second timer
            That is a very good idea except the way I have my site done is not that smart in terms of increments of frame numbers.

            I actually figured out how to do it on the next frame where it stops I can do timer.stop(); and then just copypaste everything to timer1 and timer 2 so on for every next time I want the timer to take place.

            I have a super messy system for how I did this website I was wondering if there was a way I could upload the fla so you could see how I did it. Thanks a lot.

            Christian
            • 3. Re: setting up my website on a 5 second timer
              Ned Murphy Adobe Community Professional & MVP
              Well, you could place the frame numbers into an array and increment the index of which is selected for each Timer handling event.

              I'm not sure how you have it all going at the moment, or plan to go from here, but also realize you can tell the Timer how many times to operate. The way you have it now it would keep going infinitely if you didn't tell it to stop, but you can also code it as...

              var timer:Timer = new Timer(10000, 1);

              and it will only fire the once each time you start it.
              1 person found this helpful
              • 4. Re: setting up my website on a 5 second timer
                That was exactly what I was looking for! Thanks a lot Ned sometimes the most complicated things can be done the simplest ways.

                By the way I feel like you have helped me in the past like a year ago. Thank you for helping.

                The way I have the buttons working is it just tells the fla to go to a certain frame and play this is creating problems for me because i have to give it a new function name on every page of my website so i have things like theoryyyyy111 just to make it different there has to be an easier way to call a button to do the same function on different frames with otu getting dubplicate function errors. here is a snippit of code:

                Christian
                • 5. Re: setting up my website on a 5 second timer
                  the reason why there are two "yy" after the function is because if i just had y it would be duplicate from like 100 frames back....