8 Replies Latest reply on Feb 12, 2008 6:51 AM by kglad

    Timer problem

    Level 7
      Hi,

      In my case I have more slideshows depending on the Timer class
      circulating through images.
      I call the timer from my Preloader class that loads the images as well.
      I call the Preloader class from my Navigation class passing the values
      of each slideshow (image path, number).

      My problem is that I just can't get rid of the old timers running
      underneath of each new one created.

      Any help would be appreciated.

      tamagorci
        • 1. Re: Timer problem
          robdillon Most Valuable Participant
          It's impossible to know what you might be doing wrong or not doing at all without knowing what it is that you are doing. Can you provide some code or at least an outline of the process that you are using?
          • 2. Re: Timer problem
            Rothrock Level 5
            You have to clear each timer before you set the next one. If you are loading external files and they have the timer, those timers will not be cleared by removing or replacing the external file.

            The specifics will require more information.
            • 3. Re: Timer problem
              Level 7
              Hi and thanks to both for the reply!

              Here is more specific code:
              From navigation class I create a new q_Loader object like this:

              this.newLoader = new q_Loader(navigationStage, categories ,
              numberOfImages
              , false);

              where I pass the stage, slideshow category name, number of images and if
              this is the first slideshow on stage.

              In my q_Loader I create the timer like this:

              private var timer:Timer = new Timer(totalTransitionDuration*1000, 0);
              public function testTimer():void {
              //timer.removeEventListener(TimerEvent.TIMER, notifier); //
              doesn't help anything
              timer.addEventListener(TimerEvent.TIMER, notifier);
              function notifier(event:TimerEvent):void
              {
              hideLoadedContent();
              }
              timer.start();
              }

              The problem is if I try to stop the timer anywhere in the q_Loader class
              it applies already to the new timer instance.
              On the outside I get the variable is not defined error since it exist in
              q_Loader class.

              I hope my problem is clearer.

              Thank you for your effort.
              • 4. Re: Timer problem
                kglad Adobe Community Professional & MVP
                what timer class is there in as2?
                • 5. Re: Timer problem
                  Level 7
                  I'm sorry I forgot to specify the code is in AS3.
                  > what timer class is there in as2?
                  >
                  • 6. Re: Timer problem
                    kglad Adobe Community Professional & MVP
                    each class member has its own timer. if a class member doesn't have information when it's instantiated that indicates when the timer should stop (or you fail to add that code to stop the timer when the class member is instantiated), your class member needs a method that allows the timer to be stopped by calling that method.

                    p.s. this should be in the as3 forum
                    p.p.s. use the attach code option to display code in this forum.
                    • 7. Re: Timer problem
                      Level 7
                      thank you!
                      > each class member has its own timer. if a class member doesn't have
                      > information when it's instantiated that indicates when the timer should stop
                      > (or you fail to add that code to stop the timer when the class member is
                      > instantiated), your class member needs a method that allows the timer to be
                      > stopped by calling that method.
                      >
                      >
                      i'll do so next time
                      > p.s. this should be in the as3 forum
                      >
                      will learn that as well. thanks again.
                      > p.p.s. use the attach code option to display code in this forum.
                      >
                      • 8. Re: Timer problem
                        kglad Adobe Community Professional & MVP
                        you're welcome.