6 Replies Latest reply on Sep 30, 2006 2:49 PM by kglad


      I have a website that has several pages on it that are accessible through a nav bar at the top of the site. On the home page there is a continuous playing slideshow in a movieclip. when I go to another page and then back to the homepage the slideshow doesn't work sometimes, or other times it will play one of the images multiple times, and other times will skip images.

      I have the slideshow running on an interval, and have tried using clearInterval to reset the slideshow when clicking off of the main page, so that upon returning to it, it will start again. I must be missing something to either clear the interval when going to another page or make the slideshow start over again when going back to the home page.

      Any ideas?

        • 1. Re: clearInterval
          kglad Adobe Community Professional & MVP
          what timeline contains your setInterval() statement, what timeline contains your clearInterval() statement and what are your setInterval() and clearInterval() statments?
          • 2. Re: clearInterval
            One way that can solve your problem is saving your intervalID in an array. and when you do want to clear de interval, you clear the all array with de intervalID's.

            That can solve problems when you create an intervalID,and then create another intervalID without clearing the first one. (This happens when an aplication is processing and its creates an intervalID before deleting the previous one, for example)

            Maybe it can solve your problem!
            • 3. Re: clearInterval
              kglad Adobe Community Professional & MVP
              there's no need to store all the intervals in an array and then clear them all prior to the declaration of all new setInterval() statements. simply execute clearInterval() just prior to all setInterval() statements, using the interval id of the about to be created interval.
              • 4. Re: clearInterval
                alrazzle Level 1
                Sorry I took so long to come back to this. School started up and I gave up on the project for a while.

                Below is my code. I must be doing the clearInterval() incorrectly

                var nInterval:Number;
                var fadeIn:Boolean = true;

                this.image1._alpha = 0;

                fadeIn = true;
                nInterval = setInterval(fadeImage, 50, this.image1);

                function fadeImage(mcImage:MovieClip):Void {
                if(fadeIn) {
                mcImage._alpha += 4;
                if (mcImage._alpha >= 100) {
                fadeIn = !fadeIn;
                } else {
                mcImage._alpha -= 4;
                if (mcImage._alpha <= 0) {
                fadeIn = !fadeIn;
                • 5. Re: clearInterval
                  kglad Adobe Community Professional & MVP
                  your code looks ok as long as it's not attached to a frame that executes more than once while a loop is initiated. to prevent that problem use clearInterval just prior to setInterval():

                  • 6. Re: clearInterval
                    kglad Adobe Community Professional & MVP
                    and if you're calling fadeImage using different setInterval() functions and passing different images you should use: