5 Replies Latest reply on Jul 14, 2009 11:03 PM by kglad

    Issue with clearInterval

    Sreelash Level 1

      Hi, I am trying to implement a rotateTool, in which  sequence of images are loading. While loading, the alpha of images are set to zero. Then i am using a setInterval function which follows:

       

      function startRotate(){   
          intervalId = setInterval(this, "_rotate", 30);
      }

       

      when the above function is invoked, the alpha of current image is set to 100, then the current image is assigned to previous image, then current image's index is increased by one, then the previous image's alpha is set to zero, which follows:

       

      function _rotate(){
          //trace("Curr : "+curr+" Prev : "+prev);
          ImageList[curr].Mc._parent._visible = true;   
          manageRotation(ImageList[curr].Mc._parent,ImageList[prev].Mc._parent);   
      }
      function manageRotation(currImage,prevImage){
          //trace("c : "+curr+" P : "+prev)
          currImage.tween(["_alpha"],100,0,"easeInOutSine",0,"PlaySlide()");
          prevImage.tween(["_alpha"],0,0,"easeInOutSine",0);
      }
      function PlaySlide(){   
          prev = curr;   
          if(rotRight == true){
              curr++;
              if(curr == totalImages){
                  curr = 0;
              }
          } else {
              curr--;   
              if(curr == -1){   
                  curr = totalImages-1;
              }
          }
      }

       

      Every thing working correctly when i am running it from flash IDE, but when the generated swf is running, the pause function is not working.

       

      function Pause(){
          stopRotate();
          _pause._visible = false;
          _play._visible = true;   
      }

       

      function stopRotate(){   
          txt.text = "gdkhaskld";
          //trace("Gdklshk")
          clearInterval(intervalId);
      }

       

      I am also attaching the fla with this thread . Can anybody help me.Its very urgent. Please...

        • 1. Re: Issue with clearInterval
          kglad Adobe Community Professional & MVP

          try:

           


           

          function startRotate(){   

          clearInterval(intervalId);
              intervalId = setInterval(this, "_rotate", 30);
          }

           


           

          • 2. Re: Issue with clearInterval
            Sreelash Level 1

            Hi Kglad, thank you very much. Now its working. You really helped me friend. Can I know why "clearInterval" worked with flash IDE and not working with the generated swf. One more problem with this tool is that when  i scale the images or align it to the center of the stages, after one rotation of image, a jerking is feeling. If possible can you check. Once more thank you very much Mr.Kglad.

             

            Regards,

                 Sreelash

            • 3. Re: Issue with clearInterval
              kglad Adobe Community Professional & MVP

              you probably were (re)starting an interval before the previous one was cleared.  once that happens, your code will not function correctly.

               

              i don't see any rotation code and so am unable to say why you're having a problem with that.

              • 4. Re: Issue with clearInterval
                Sreelash Level 1

                What I meant by rotation is that, I am loading sequence of images of a product which have taken at each 5 degree in order to get the feel of rotating. Did u compile my application. Thus you can see that bottle is rotating. Actually I am loading the images, not using any rotate code.Did you get me?I am using a class to load images named SlideShowImageLoader. There i have commented the code to scale and aligning the images to center.If you have time, will you check it?

                • 5. Re: Issue with clearInterval
                  kglad Adobe Community Professional & MVP

                  i don't usually download and correct files unless i'm hired.