16 Replies Latest reply on Oct 27, 2010 1:58 PM by kglad

    AS2 Timer needs to pause

    T. Backx

      Good morning everyone,

       

      I'm making a bannerslider that's going every 7 seconds to the next Movieclip/Image.

       

      But i made a play and pause button in it so that the timer would pause.

      But my problem is that the Timer doesn't pause. And I can't see the problem !

       

      Maybe can somebody put me in the rigth direction?

       

      My AS is as follows:

      slides = 5; //<------- Hoeveel afbeeldingen er staan
      wait = 7; // <------- Aantal seconde per afbeelding
      playclip._visible = false;

      contentHold.content1.button.onPress = function() {
      getURL("
      www.visualbrand.nl/kijken.html", "_self");
      };
      contentHold.content2.button.onPress = function() {
      getURL("
      http://www.bestsellers.nl/catalog/category/view/id/249", "_self");
      };
      contentHold.content3.button.onPress = function() {
      getURL("
      http://www.bestsellers.nl/music/8718036994508.html", "_self");
      };
      contentHold.content4.button.onPress = function() {
      getURL("
      http://http://www.bestsellers.nl/5099990631825.html", "_self");
      };
      contentHold.content5.button.onPress = function() {
      getURL("
      http://www.bestsellers.nl/catalog/category/view/id/270", "_self");
      };
      contentHold.content6.button.onPress = function() {
      getURL("
      http://www.visualbrand.nl", "_self");
      };
      var currentPosition = contentHold.content1._x;
      var startFlag = false;
      menuSlide = function (input) {
      if (startFlag == false) {
        startFlag = true;
        var _loc1 = input._x;
        var distanceMoved = 0;
        var distanceToMove = Math.abs(_loc1-currentPosition);
        var finalSpeed = 3.000000E-001;
        var currentSpeed = 0;
        var dir = 1;
      //----------> SLIDE VAN LINKS/RECHTS NAAR RECHTS/LINKS <-----------
        if (currentPosition<=_loc1) {
         dir = -1;
        } else if (currentPosition>_loc1) {
         dir = 1;
        }
        // end else if
        contentHold.onEnterFrame = function() {
         currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);
         distanceMoved = distanceMoved+currentSpeed;
         contentHold._x = contentHold._x+dir*currentSpeed;
         if (Math.abs(distanceMoved-distanceToMove)<=1) {
          contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;
          currentPosition = input._x;
          startFlag = false;
          delete contentHold.onEnterFrame;
         }
         // end if
        };
      }
      // end if
      };
      bAll.mov1.b1.onRelease = function() {
      menuSlide(contentHold.content1);
      bAll.mov1.gotoAndPlay(1);
      bAll.mov2.gotoAndPlay(1);
      bAll.mov3.gotoAndPlay(1);
      bAll.mov4.gotoAndPlay(1);
      bAll.mov5.gotoAndPlay(1);
      bAll.mov6.gotoAndPlay(1);
      bAll.mov7.gotoAndPlay(1);
      };
      bAll.mov2.b2.onRelease = function() {
      menuSlide(contentHold.content2);
      bAll.mov1.gotoAndPlay(175);
      bAll.mov2.gotoAndPlay(175);
      bAll.mov3.gotoAndPlay(175);
      bAll.mov4.gotoAndPlay(175);
      bAll.mov5.gotoAndPlay(175);
      bAll.mov6.gotoAndPlay(175);
      bAll.mov7.gotoAndPlay(175);
      };
      bAll.mov3.b3.onRelease = function() {
      menuSlide(contentHold.content3);
      bAll.mov1.gotoAndPlay(350);
      bAll.mov2.gotoAndPlay(350);
      bAll.mov3.gotoAndPlay(350);
      bAll.mov4.gotoAndPlay(350);
      bAll.mov5.gotoAndPlay(350);
      bAll.mov6.gotoAndPlay(350);
      bAll.mov7.gotoAndPlay(350);
      };
      bAll.mov4.b4.onRelease = function() {
      menuSlide(contentHold.content4);
      bAll.mov1.gotoAndPlay(525);
      bAll.mov2.gotoAndPlay(525);
      bAll.mov3.gotoAndPlay(525);
      bAll.mov4.gotoAndPlay(525);
      bAll.mov5.gotoAndPlay(525);
      bAll.mov6.gotoAndPlay(525);
      bAll.mov7.gotoAndPlay(525);
      };
      bAll.mov5.b5.onRelease = function() {
      menuSlide(contentHold.content5);
      bAll.mov1.gotoAndPlay(700);
      bAll.mov2.gotoAndPlay(700);
      bAll.mov3.gotoAndPlay(700);
      bAll.mov4.gotoAndPlay(700);
      bAll.mov5.gotoAndPlay(700);
      bAll.mov6.gotoAndPlay(700);
      bAll.mov7.gotoAndPlay(700);
      };
      bAll.mov6.b6.onRelease = function() {
      menuSlide(contentHold.content6);
      bAll.mov1.gotoAndPlay(875);
      bAll.mov2.gotoAndPlay(875);
      bAll.mov3.gotoAndPlay(875);
      bAll.mov4.gotoAndPlay(875);
      bAll.mov5.gotoAndPlay(875);
      bAll.mov6.gotoAndPlay(875);
      bAll.mov7.gotoAndPlay(875);
      };
      bAll.mov7.b7.onRelease = function() {
      menuSlide(contentHold.content7);
      bAll.mov1.gotoAndPlay(1050);
      bAll.mov2.gotoAndPlay(1050);
      bAll.mov3.gotoAndPlay(1050);
      bAll.mov4.gotoAndPlay(1050);
      bAll.mov5.gotoAndPlay(1050);
      bAll.mov6.gotoAndPlay(1050);
      bAll.mov7.gotoAndPlay(1050);
      };

      playclip.onRelease = function () {
      lastTime.play();
      pauze._visible = true;
      playclip._visible = false;
      };

      pauze.onRelease = function () {
      lastTime.stop();
      playclip._visible = true;
      pauze._visible = false;
      };

      count = 1;
      delay = 1;
      lastTime = 0;
      _root.onEnterFrame = function() {
      if (delay == 1) {
        if (Math.floor(getTimer()/1000) == lastTime+1) {
         delay = 0;
        }
        // end if
      } else if (Math.floor(getTimer()/1000) == lastTime+wait) {
        lastTime = Math.floor(getTimer()/1000);
        delay = 1;
        if (count == 1) {
         move = 1;
        } else if (count == slides) {
         move = 1-slides;
        }
        // end else if
        count = count+move;
        trace(count);
        menuSlide(contentHold["content"+count]);
      }
      // end else if
      };

       

      Thank you in advance !

        • 1. Re: AS2 Timer needs to pause
          kglad Adobe Community Professional & MVP

          use the trace() function to debug your code.

           

          but i can tell you checking for equality in those timer if-statements like

           

          Math.floor(getTimer()/1000) == lastTime+1

           

          are pretty unlikely to ever resolve to true.

          • 2. Re: AS2 Timer needs to pause
            T. Backx Level 1

            Thank you for replying!

             

            And I did what you sad to me. I used the trace fuction 3 times. And I now know a bit how the timer works.

            But after I changed the code. It still doesn't pause.

             

            But there is a change like you say that this problem can't be solved?

             

            Here are my changes:

            playclip.onRelease = function () {

            delay.play();

            pauze._visible = true;

            playclip._visible = false;

            };


            pauze.onRelease = function () {

            delay.pause();

            playclip._visible = true;

            pauze._visible = false;

            };


            count = 1;

            delay = 1;

            lastTime = 0;

            _root.onEnterFrame = function() {

            if (delay == 1) {

            if (Math.floor(getTimer()/1000) == lastTime+1) {

            delay = 0;

            trace ("after one second")

            }

            // end if

            } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

            lastTime = Math.floor(getTimer()/1000);

            delay = 1;

            if (count == 1) {

            move = 1;

            trace ("begins")

             

            } else if (count == slides) {

            move = 1-slides;

            trace ("return")

            }

            // end else if

            count = count+move;

            trace(count);

            menuSlide(contentHold["content"+count]);

            }

            // end else if

            };

             

            And Thank you for your help so far !

            • 3. Re: AS2 Timer needs to pause
              kglad Adobe Community Professional & MVP

              do you ever see any of those if-conditions met?  if not you need to use something like the following.  notice how, instead of testing for exact equality, you're testing for getTimer()/1000 to be close to (lastTime+1):

               


               

              playclip.onRelease = function () {

              delay.play();

              pauze._visible = true;

              playclip._visible = false;

              };


              pauze.onRelease = function () {

              delay.pause();

              playclip._visible = true;

              pauze._visible = false;

              };


              count = 1;

              delay = 1;

              lastTime = 0;

              _root.onEnterFrame = function() {

              if (delay == 1) {

              // assign tolerance to something your expect to be met

              if (Math.abs(Math.floor(getTimer()/1000) - (lastTime+1))< tolerance) {

              delay = 0;

              trace ("after one second")

              }

              // end if

              } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

              lastTime = Math.floor(getTimer()/1000);

              delay = 1;

              if (count == 1) {

              move = 1;

              trace ("begins")

               

              } else if (count == slides) {

              move = 1-slides;

              trace ("return")

              }

              // end else if

              count = count+move;

              trace(count);

              menuSlide(contentHold["content"+count]);

              }

              // end else if

              };

               

              And Thank you for your help so far !

               

              then do the same for your other if-conditions that are never met.

              • 4. Re: AS2 Timer needs to pause
                T. Backx Level 1

                No I never met them.

                 

                And I want to pause the time if the pause button is pressed (pauze).

                 

                So I only want to pause the timer. Not that it's close to the (lastTimer +1)

                 

                I'm sorry that I don't get it. But I'm really trying to!

                • 5. Re: AS2 Timer needs to pause
                  kglad Adobe Community Professional & MVP

                  use:

                   


                   

                  var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);
                  var count:Number = 0;

                   

                  playclip.onRelease = function () {

                  delay.play();

                  pauze._visible = true;

                  playclip._visible = false;

                  clearInterval(autoAdvanceI);

                  autoAdvanceI=setInterval(autoAdvanceF,7000);

                  };


                  pauze.onRelease = function () {

                  delay.pause();

                  playclip._visible = true;

                  pauze._visible = false;

                  clearInterval(autoAdvanceI);

                  };

                   

                  function autoAdvanceF():Void{

                  count = count%slides;

                  menuSlide(contentHold["content"+(count+1)]);

                  }



                  • 6. Re: AS2 Timer needs to pause
                    T. Backx Level 1

                    Thank you for your help.

                     

                    But the interval doesn't do its work.

                    And the play and pause button dissapper after you clicked them.

                     

                    Thank you for so far!

                    • 7. Re: AS2 Timer needs to pause
                      T. Backx Level 1

                      The pauze button works!!  My fault: missed a letter.

                       

                      But the timer still doesn't

                      • 8. Re: AS2 Timer needs to pause
                        kglad Adobe Community Professional & MVP

                        copy and paste the code you're using and include your menuSlide() function.


                        • 9. Re: AS2 Timer needs to pause
                          T. Backx Level 1

                          I did and it doesn't pause

                           

                          look:

                          slides = 7;

                          wait = 7;

                          playclip._visible = false


                          contentHold.content1.button.onPress = function() {

                          getURL("www.visualbrand.nl/kijken.html", "_self");

                          };

                          contentHold.content2.button.onPress = function() {

                          getURL("http://www.bestsellers.nl/catalog/category/view/id/249", "_self");

                          };

                          contentHold.content3.button.onPress = function() {

                          getURL("http://www.bestsellers.nl/music/8718036994508.html", "_self");

                          };

                          contentHold.content4.button.onPress = function() {

                          getURL("http://http://www.bestsellers.nl/5099990631825.html", "_self");

                          };

                          contentHold.content5.button.onPress = function() {

                          getURL("http://www.bestsellers.nl/catalog/category/view/id/270", "_self");

                          };

                          contentHold.content6.button.onPress = function() {

                          getURL("http://www.visualbrand.nl", "_self");

                          };

                          var currentPosition = contentHold.content1._x;

                          var startFlag = false;

                          menuSlide = function (input) {

                          if (startFlag == false) {

                          startFlag = true;

                          var _loc1 = input._x;

                          var distanceMoved = 0;

                          var distanceToMove = Math.abs(_loc1-currentPosition);

                          var finalSpeed = 3.000000E-001;

                          var currentSpeed = 0;

                          var dir = 1;

                          //----------> SLIDE VAN LINKS/RECHTS NAAR RECHTS/LINKS <-----------

                          if (currentPosition<=_loc1) {

                          dir = -1;

                          } else if (currentPosition>_loc1) {

                          dir = 1;

                          }

                          // end else if

                          contentHold.onEnterFrame = function() {

                          currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);

                          distanceMoved = distanceMoved+currentSpeed;

                          contentHold._x = contentHold._x+dir*currentSpeed;

                          if (Math.abs(distanceMoved-distanceToMove)<=1) {

                          contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;

                          currentPosition = input._x;

                          startFlag = false;

                          delete contentHold.onEnterFrame;

                          }

                          // end if

                          };

                          }

                          // end if

                          };

                          bAll.mov1.b1.onRelease = function() {

                          menuSlide(contentHold.content1);

                          bAll.mov1.gotoAndPlay(1);

                          bAll.mov2.gotoAndPlay(1);

                          bAll.mov3.gotoAndPlay(1);

                          bAll.mov4.gotoAndPlay(1);

                          bAll.mov5.gotoAndPlay(1);

                          bAll.mov6.gotoAndPlay(1);

                          bAll.mov7.gotoAndPlay(1);

                          };

                          bAll.mov2.b2.onRelease = function() {

                          menuSlide(contentHold.content2);

                          bAll.mov1.gotoAndPlay(175);

                          bAll.mov2.gotoAndPlay(175);

                          bAll.mov3.gotoAndPlay(175);

                          bAll.mov4.gotoAndPlay(175);

                          bAll.mov5.gotoAndPlay(175);

                          bAll.mov6.gotoAndPlay(175);

                          bAll.mov7.gotoAndPlay(175);

                          };

                          bAll.mov3.b3.onRelease = function() {

                          menuSlide(contentHold.content3);

                          bAll.mov1.gotoAndPlay(350);

                          bAll.mov2.gotoAndPlay(350);

                          bAll.mov3.gotoAndPlay(350);

                          bAll.mov4.gotoAndPlay(350);

                          bAll.mov5.gotoAndPlay(350);

                          bAll.mov6.gotoAndPlay(350);

                          bAll.mov7.gotoAndPlay(350);

                          };

                          bAll.mov4.b4.onRelease = function() {

                          menuSlide(contentHold.content4);

                          bAll.mov1.gotoAndPlay(525);

                          bAll.mov2.gotoAndPlay(525);

                          bAll.mov3.gotoAndPlay(525);

                          bAll.mov4.gotoAndPlay(525);

                          bAll.mov5.gotoAndPlay(525);

                          bAll.mov6.gotoAndPlay(525);

                          bAll.mov7.gotoAndPlay(525);

                          };

                          bAll.mov5.b5.onRelease = function() {

                          menuSlide(contentHold.content5);

                          bAll.mov1.gotoAndPlay(700);

                          bAll.mov2.gotoAndPlay(700);

                          bAll.mov3.gotoAndPlay(700);

                          bAll.mov4.gotoAndPlay(700);

                          bAll.mov5.gotoAndPlay(700);

                          bAll.mov6.gotoAndPlay(700);

                          bAll.mov7.gotoAndPlay(700);

                          };

                          bAll.mov6.b6.onRelease = function() {

                          menuSlide(contentHold.content6);

                          bAll.mov1.gotoAndPlay(875);

                          bAll.mov2.gotoAndPlay(875);

                          bAll.mov3.gotoAndPlay(875);

                          bAll.mov4.gotoAndPlay(875);

                          bAll.mov5.gotoAndPlay(875);

                          bAll.mov6.gotoAndPlay(875);

                          bAll.mov7.gotoAndPlay(875);

                          };

                          bAll.mov7.b7.onRelease = function() {

                          menuSlide(contentHold.content7);

                          bAll.mov1.gotoAndPlay(1050);

                          bAll.mov2.gotoAndPlay(1050);

                          bAll.mov3.gotoAndPlay(1050);

                          bAll.mov4.gotoAndPlay(1050);

                          bAll.mov5.gotoAndPlay(1050);

                          bAll.mov6.gotoAndPlay(1050);

                          bAll.mov7.gotoAndPlay(1050);

                          };


                          var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                          var count:Number = 0;


                          playclip.onRelease = function () {

                          delay.play();

                          pauze._visible = true;

                          playclip._visible = false;

                          clearInterval(autoAdvanceI);

                          autoAdvanceI=setInterval(autoAdvanceF,7000);

                          };


                          pauze.onRelease = function () {

                          delay.pause();

                          playclip._visible = true;

                          pauze._visible = false;

                          clearInterval(autoAdvanceI);

                          };


                          function autoAdvanceF():Void{

                          count = count%slides;

                          menuSlide(contentHold["content"+(count+1)]);

                          }


                          count = 1;

                          delay = 1;

                          lastTime = 0;

                          _root.onEnterFrame = function() {

                          if (delay == 1) {

                          if (Math.floor(getTimer()/1000) == lastTime+1) {

                          delay = 0;

                          }

                          // end if

                          } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

                          lastTime = Math.floor(getTimer()/1000);

                          delay = 1;

                          if (count == 1) {

                          move = 1;

                          } else if (count == slides) {

                          move = 1-slides;

                          }

                          // end else if

                          count = count+move;

                          trace(count);

                          menuSlide(contentHold["content"+count]);

                          }

                          // end else if

                          };

                          • 10. Re: AS2 Timer needs to pause
                            kglad Adobe Community Professional & MVP

                            delete your timer code:

                             

                            count = 1;

                            delay = 1;

                            lastTime = 0;

                            _root.onEnterFrame = function() {

                            if (delay == 1) {

                            if (Math.floor(getTimer()/1000) == lastTime+1) {

                            delay = 0;

                            }

                            // end if

                            } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

                            lastTime = Math.floor(getTimer()/1000);

                            delay = 1;

                            if (count == 1) {

                            move = 1;

                            } else if (count == slides) {

                            move = 1-slides;

                            }

                            // end else if

                            count = count+move;

                            trace(count);

                            menuSlide(contentHold["content"+count]);

                            }

                            // end else if

                            };

                             


                            and where's that function?

                            • 11. Re: AS2 Timer needs to pause
                              T. Backx Level 1

                              the fuction for the timer is?

                               

                              Well that's the function you've got.

                              And yes it works if I click op the playbutton. But before that the timer doesn't count. it only has to pause of you click on the pause button.

                              So the code as it is now doesn't work complety.

                               

                              But thank you for so far !

                               

                              Can you maybe explain a bit (simple) what you've done? So that I'll understand it completely?!

                               

                              Greets,

                               

                              Tim

                               

                              slides = 7;

                              wait = 7;

                              playclip._visible = false


                              contentHold.content1.button.onPress = function() {

                              getURL("www.visualbrand.nl/kijken.html", "_self");

                              };

                              contentHold.content2.button.onPress = function() {

                              getURL("http://www.bestsellers.nl/catalog/category/view/id/249", "_self");

                              };

                              contentHold.content3.button.onPress = function() {

                              getURL("http://www.bestsellers.nl/music/8718036994508.html", "_self");

                              };

                              contentHold.content4.button.onPress = function() {

                              getURL("http://http://www.bestsellers.nl/5099990631825.html", "_self");

                              };

                              contentHold.content5.button.onPress = function() {

                              getURL("http://www.bestsellers.nl/catalog/category/view/id/270", "_self");

                              };

                              contentHold.content6.button.onPress = function() {

                              getURL("http://www.visualbrand.nl", "_self");

                              };

                              var currentPosition = contentHold.content1._x;

                              var startFlag = false;

                              menuSlide = function (input) {

                              if (startFlag == false) {

                              startFlag = true;

                              var _loc1 = input._x;

                              var distanceMoved = 0;

                              var distanceToMove = Math.abs(_loc1-currentPosition);

                              var finalSpeed = 3.000000E-001;

                              var currentSpeed = 0;

                              var dir = 1;

                              //----------> SLIDE VAN LINKS/RECHTS NAAR RECHTS/LINKS <-----------

                              if (currentPosition<=_loc1) {

                              dir = -1;

                              } else if (currentPosition>_loc1) {

                              dir = 1;

                              }

                              // end else if

                              contentHold.onEnterFrame = function() {

                              currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);

                              distanceMoved = distanceMoved+currentSpeed;

                              contentHold._x = contentHold._x+dir*currentSpeed;

                              if (Math.abs(distanceMoved-distanceToMove)<=1) {

                              contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;

                              currentPosition = input._x;

                              startFlag = false;

                              delete contentHold.onEnterFrame;

                              }

                              // end if

                              };

                              }

                              // end if

                              };

                              bAll.mov1.b1.onRelease = function() {

                              menuSlide(contentHold.content1);

                              bAll.mov1.gotoAndPlay(1);

                              bAll.mov2.gotoAndPlay(1);

                              bAll.mov3.gotoAndPlay(1);

                              bAll.mov4.gotoAndPlay(1);

                              bAll.mov5.gotoAndPlay(1);

                              bAll.mov6.gotoAndPlay(1);

                              bAll.mov7.gotoAndPlay(1);

                              };

                              bAll.mov2.b2.onRelease = function() {

                              menuSlide(contentHold.content2);

                              bAll.mov1.gotoAndPlay(175);

                              bAll.mov2.gotoAndPlay(175);

                              bAll.mov3.gotoAndPlay(175);

                              bAll.mov4.gotoAndPlay(175);

                              bAll.mov5.gotoAndPlay(175);

                              bAll.mov6.gotoAndPlay(175);

                              bAll.mov7.gotoAndPlay(175);

                              };

                              bAll.mov3.b3.onRelease = function() {

                              menuSlide(contentHold.content3);

                              bAll.mov1.gotoAndPlay(350);

                              bAll.mov2.gotoAndPlay(350);

                              bAll.mov3.gotoAndPlay(350);

                              bAll.mov4.gotoAndPlay(350);

                              bAll.mov5.gotoAndPlay(350);

                              bAll.mov6.gotoAndPlay(350);

                              bAll.mov7.gotoAndPlay(350);

                              };

                              bAll.mov4.b4.onRelease = function() {

                              menuSlide(contentHold.content4);

                              bAll.mov1.gotoAndPlay(525);

                              bAll.mov2.gotoAndPlay(525);

                              bAll.mov3.gotoAndPlay(525);

                              bAll.mov4.gotoAndPlay(525);

                              bAll.mov5.gotoAndPlay(525);

                              bAll.mov6.gotoAndPlay(525);

                              bAll.mov7.gotoAndPlay(525);

                              };

                              bAll.mov5.b5.onRelease = function() {

                              menuSlide(contentHold.content5);

                              bAll.mov1.gotoAndPlay(700);

                              bAll.mov2.gotoAndPlay(700);

                              bAll.mov3.gotoAndPlay(700);

                              bAll.mov4.gotoAndPlay(700);

                              bAll.mov5.gotoAndPlay(700);

                              bAll.mov6.gotoAndPlay(700);

                              bAll.mov7.gotoAndPlay(700);

                              };

                              bAll.mov6.b6.onRelease = function() {

                              menuSlide(contentHold.content6);

                              bAll.mov1.gotoAndPlay(875);

                              bAll.mov2.gotoAndPlay(875);

                              bAll.mov3.gotoAndPlay(875);

                              bAll.mov4.gotoAndPlay(875);

                              bAll.mov5.gotoAndPlay(875);

                              bAll.mov6.gotoAndPlay(875);

                              bAll.mov7.gotoAndPlay(875);

                              };

                              bAll.mov7.b7.onRelease = function() {

                              menuSlide(contentHold.content7);

                              bAll.mov1.gotoAndPlay(1050);

                              bAll.mov2.gotoAndPlay(1050);

                              bAll.mov3.gotoAndPlay(1050);

                              bAll.mov4.gotoAndPlay(1050);

                              bAll.mov5.gotoAndPlay(1050);

                              bAll.mov6.gotoAndPlay(1050);

                              bAll.mov7.gotoAndPlay(1050);

                              };


                              var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                              var count:Number = 0;


                              playclip.onRelease = function () {

                              delay.play();

                              pauze._visible = true;

                              playclip._visible = false;

                              clearInterval(autoAdvanceI);

                              autoAdvanceI=setInterval(autoAdvanceF,7000);

                              };


                              pauze.onRelease = function () {

                              delay.pause();

                              playclip._visible = true;

                              pauze._visible = false;

                              clearInterval(autoAdvanceI);

                              };


                              function autoAdvanceF():Void{

                              count = count%slides;

                              menuSlide(contentHold["content"+(count+1)]);

                              }


                              //count = 1;

                              //delay = 1;

                              //lastTime = 0;

                              //_root.onEnterFrame = function() {

                              // if (delay == 1) {

                              // if (Math.floor(getTimer()/1000) == lastTime+1) {

                              // delay = 0;

                              // }

                              // // end if

                              // } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

                              // lastTime = Math.floor(getTimer()/1000);

                              // delay = 1;

                              // if (count == 1) {

                              // move = 1;

                              // } else if (count == slides) {

                              // move = 1-slides;

                              // }

                              // // end else if

                              // count = count+move;

                              // trace(count);

                              // menuSlide(contentHold["content"+count]);

                              // }

                              // // end else if

                              //};

                              • 12. Re: AS2 Timer needs to pause
                                kglad Adobe Community Professional & MVP

                                oops, i had a typo.  use:

                                 

                                 

                                clearInterval(autoAdvanceI);

                                //  start a loop that calls autoAdvanceF() every 7000 ms = 7 seconds

                                var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                                // my count variable ranges from 0 to slides-1

                                var count:Number = 0;


                                function autoAdvanceF():Void{

                                // increment count and reset count if incremented to slides

                                count = (count+1)%slides;

                                // pass contentHold["content"+(count+1)] to menuSlide()

                                menuSlide(contentHold["content"+(count+1)]);

                                }

                                1 person found this helpful
                                • 13. Re: AS2 Timer needs to pause
                                  T. Backx Level 1

                                  Almost !!!

                                   

                                  But now i've got an error with the code:

                                   

                                  *count = (count+1)%slides;*

                                   

                                  I did what you sad but the error doesn;t make sence rigth?!

                                   

                                  slides = 7;

                                  wait = 7;

                                  playclip._visible = false


                                  contentHold.content1.button.onPress = function() {

                                  getURL("www.visualbrand.nl/kijken.html", "_self");

                                  };

                                  contentHold.content2.button.onPress = function() {

                                  getURL("http://www.bestsellers.nl/catalog/category/view/id/249", "_self");

                                  };

                                  contentHold.content3.button.onPress = function() {

                                  getURL("http://www.bestsellers.nl/music/8718036994508.html", "_self");

                                  };

                                  contentHold.content4.button.onPress = function() {

                                  getURL("http://http://www.bestsellers.nl/5099990631825.html", "_self");

                                  };

                                  contentHold.content5.button.onPress = function() {

                                  getURL("http://www.bestsellers.nl/catalog/category/view/id/270", "_self");

                                  };

                                  contentHold.content6.button.onPress = function() {

                                  getURL("http://www.visualbrand.nl", "_self");

                                  };

                                  var currentPosition = contentHold.content1._x;

                                  var startFlag = false;

                                  menuSlide = function (input) {

                                  if (startFlag == false) {

                                  startFlag = true;

                                  var _loc1 = input._x;

                                  var distanceMoved = 0;

                                  var distanceToMove = Math.abs(_loc1-currentPosition);

                                  var finalSpeed = 3.000000E-001;

                                  var currentSpeed = 0;

                                  var dir = 1;

                                  //----------> SLIDE VAN LINKS/RECHTS NAAR RECHTS/LINKS <-----------

                                  if (currentPosition<=_loc1) {

                                  dir = -1;

                                  } else if (currentPosition>_loc1) {

                                  dir = 1;

                                  }

                                  // end else if

                                  contentHold.onEnterFrame = function() {

                                  currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);

                                  distanceMoved = distanceMoved+currentSpeed;

                                  contentHold._x = contentHold._x+dir*currentSpeed;

                                  if (Math.abs(distanceMoved-distanceToMove)<=1) {

                                  contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;

                                  currentPosition = input._x;

                                  startFlag = false;

                                  delete contentHold.onEnterFrame;

                                  }

                                  // end if

                                  };

                                  }

                                  // end if

                                  };

                                  bAll.mov1.b1.onRelease = function() {

                                  menuSlide(contentHold.content1);

                                  bAll.mov1.gotoAndPlay(1);

                                  bAll.mov2.gotoAndPlay(1);

                                  bAll.mov3.gotoAndPlay(1);

                                  bAll.mov4.gotoAndPlay(1);

                                  bAll.mov5.gotoAndPlay(1);

                                  bAll.mov6.gotoAndPlay(1);

                                  bAll.mov7.gotoAndPlay(1);

                                  };

                                  bAll.mov2.b2.onRelease = function() {

                                  menuSlide(contentHold.content2);

                                  bAll.mov1.gotoAndPlay(175);

                                  bAll.mov2.gotoAndPlay(175);

                                  bAll.mov3.gotoAndPlay(175);

                                  bAll.mov4.gotoAndPlay(175);

                                  bAll.mov5.gotoAndPlay(175);

                                  bAll.mov6.gotoAndPlay(175);

                                  bAll.mov7.gotoAndPlay(175);

                                  };

                                  bAll.mov3.b3.onRelease = function() {

                                  menuSlide(contentHold.content3);

                                  bAll.mov1.gotoAndPlay(350);

                                  bAll.mov2.gotoAndPlay(350);

                                  bAll.mov3.gotoAndPlay(350);

                                  bAll.mov4.gotoAndPlay(350);

                                  bAll.mov5.gotoAndPlay(350);

                                  bAll.mov6.gotoAndPlay(350);

                                  bAll.mov7.gotoAndPlay(350);

                                  };

                                  bAll.mov4.b4.onRelease = function() {

                                  menuSlide(contentHold.content4);

                                  bAll.mov1.gotoAndPlay(525);

                                  bAll.mov2.gotoAndPlay(525);

                                  bAll.mov3.gotoAndPlay(525);

                                  bAll.mov4.gotoAndPlay(525);

                                  bAll.mov5.gotoAndPlay(525);

                                  bAll.mov6.gotoAndPlay(525);

                                  bAll.mov7.gotoAndPlay(525);

                                  };

                                  bAll.mov5.b5.onRelease = function() {

                                  menuSlide(contentHold.content5);

                                  bAll.mov1.gotoAndPlay(700);

                                  bAll.mov2.gotoAndPlay(700);

                                  bAll.mov3.gotoAndPlay(700);

                                  bAll.mov4.gotoAndPlay(700);

                                  bAll.mov5.gotoAndPlay(700);

                                  bAll.mov6.gotoAndPlay(700);

                                  bAll.mov7.gotoAndPlay(700);

                                  };

                                  bAll.mov6.b6.onRelease = function() {

                                  menuSlide(contentHold.content6);

                                  bAll.mov1.gotoAndPlay(875);

                                  bAll.mov2.gotoAndPlay(875);

                                  bAll.mov3.gotoAndPlay(875);

                                  bAll.mov4.gotoAndPlay(875);

                                  bAll.mov5.gotoAndPlay(875);

                                  bAll.mov6.gotoAndPlay(875);

                                  bAll.mov7.gotoAndPlay(875);

                                  };

                                  bAll.mov7.b7.onRelease = function() {

                                  menuSlide(contentHold.content7);

                                  bAll.mov1.gotoAndPlay(1050);

                                  bAll.mov2.gotoAndPlay(1050);

                                  bAll.mov3.gotoAndPlay(1050);

                                  bAll.mov4.gotoAndPlay(1050);

                                  bAll.mov5.gotoAndPlay(1050);

                                  bAll.mov6.gotoAndPlay(1050);

                                  bAll.mov7.gotoAndPlay(1050);

                                  };


                                  var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                                  var count:Number = 0;


                                  playclip.onRelease = function () {

                                  delay.play();

                                  pauze._visible = true;

                                  playclip._visible = false;

                                  clearInterval(autoAdvanceI);

                                  //  start a loop that calls autoAdvanceF() every 7000 ms = 7 seconds

                                  var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                                  // my count variable ranges from 0 to slides-1

                                  var count:Number = 0;


                                  pauze.onRelease = function () {

                                  delay.pause();

                                  playclip._visible = true;

                                  pauze._visible = false;

                                  clearInterval(autoAdvanceI);

                                  };


                                  function autoAdvanceF():Void{

                                  // increment count and reset count if incremented to slides

                                  *count = (count+1)%slides;*

                                  // pass contentHold["content"+(count+1)] to menuSlide()

                                  menuSlide(contentHold["content"+(count+1)]);

                                  }


                                  //count = 1;

                                  //delay = 1;

                                  //lastTime = 0;

                                  //_root.onEnterFrame = function() {

                                  // if (delay == 1) {

                                  // if (Math.floor(getTimer()/1000) == lastTime+1) {

                                  // delay = 0;

                                  // }

                                  // // end if

                                  // } else if (Math.floor(getTimer()/1000) == lastTime+wait) {

                                  // lastTime = Math.floor(getTimer()/1000);

                                  // delay = 1;

                                  // if (count == 1) {

                                  // move = 1;

                                  // } else if (count == slides) {

                                  // move = 1-slides;

                                  // }

                                  // // end else if

                                  // count = count+move;

                                  // trace(count);

                                  // menuSlide(contentHold["content"+count]);

                                  // }

                                  // // end else if

                                  //};

                                  • 14. Re: AS2 Timer needs to pause
                                    kglad Adobe Community Professional & MVP

                                    remove those asterisks.

                                    • 15. Re: AS2 Timer needs to pause
                                      T. Backx Level 1

                                      Thank you very much kglad !

                                       

                                      you're the one who "saved" me from a lot of days with headaces !

                                       

                                      It works!

                                       

                                      But what was exectly the change if we translate it to "normal" english?

                                       

                                      Thank you for all your efford!

                                       

                                      Greets,

                                       

                                      Tim

                                      • 16. Re: AS2 Timer needs to pause
                                        kglad Adobe Community Professional & MVP

                                        you're welcome.

                                         

                                        the comments from above explain the code in english:

                                         

                                        clearInterval(autoAdvanceI);

                                        //  start a loop that calls autoAdvanceF() every 7000 ms = 7 seconds

                                        var autoAdvanceI:Number = setInterval(autoAdvanceF,7000);

                                        // my count variable ranges from 0 to slides-1

                                        var count:Number = 0;


                                        function autoAdvanceF():Void{

                                        // increment count and reset count if incremented to slides

                                        count = (count+1)%slides;

                                        // pass contentHold["content"+(count+1)] to menuSlide()

                                        menuSlide(contentHold["content"+(count+1)]);

                                        }