5 Replies Latest reply on Jun 18, 2008 3:54 PM by kglad

    Pause for a few seconds (k)

    Level 7
      I have searched and searched but cannot for the life of me get a timer
      that works.

      I have a movieClip that has three frames and two layers (Actions and a
      layer with a movieClip entitled mcNoreen)


      FRAME 1 ACTIONSCRIPT:

      stop();
      // import tween classes
      import mx.transitions.Tween;
      import mx.transitions.easing.*;
      //
      var Animation:Object;
      //
      Animation = new Tween(mcNoreen, "_alpha", Regular.easeInOut, 0, 100,
      _global.FadeInTime, true);
      Animation.onMotionFinished = function() {
      nextFrame();
      };


      FRAME 2 ACTIONSCRIPT:

      stop();
      var myInterval:Number;
      clearInterval(myInterval);
      myInterval = setInterval(wait, 4000);
      function wait() {
      clearInterval(myInterval);
      play();
      }

      FRAME 3 ACTIONSCRIPT:

      stop();
      // import tween classes
      import mx.transitions.Tween;
      import mx.transitions.easing.*;
      //
      var FadeOutAnimation:Object;
      //
      FadeOutAnimation = new Tween(mcNoreen, "_alpha", Regular.easeInOut, 100,
      0, _global.FadeOutTime, true);
      FadeOutAnimation.onMotionFinished = function() {
      _root.nextFrame();
      };


      It's the frame in the middle(#2) that has become my arch nemesis. I have
      tried every method I can find on the web and none are working. Instead
      of pausing it seems to go right out of the movieClip.

      All I want to do is pause the playhead on a frame for a few seconds then
      move on to the next frame.

      It shouldn't be this hard.

      -Kirk
        • 1. Re: Pause for a few seconds (k)
          kglad Adobe Community Professional & MVP
          you're all over the place with your scoping: in onMotionFinished you're within scope of your tween and in wait() you're in scope of no object.

          make it easy on yourself. if you want to control the main timeline, create a reference to it and use that reference to apply stop() and play() and nextFrame etc:

          • 2. Re: Pause for a few seconds (k)
            Level 7
            That appears to work(thanks), it looks like it is pausing on the second
            frame. The weird part is that it goes from the second frame of this
            movieClip to the next frame of the _root timeline, skipping the third
            frame that has the FadeOut tween.

            Any thoughts? The frame this movie clip sits on in the main timeline has
            a stop action on it, so it shouldn't jump until the FadeOut is done.

            -Kirk





            kglad wrote:
            > you're all over the place with your scoping: in onMotionFinished you're within
            > scope of your tween and in wait() you're in scope of no object.
            >
            > make it easy on yourself. if you want to control the main timeline, create a
            > reference to it and use that reference to apply stop() and play() and nextFrame
            > etc:
            >
            >
            >
            > var tl:MovieClip=this;
            > stop();
            >
            > // import tween classes
            > import mx.transitions.Tween;
            > import mx.transitions.easing.*;
            > //
            > var Animation:Object;
            > //
            > Animation = new Tween(mcNoreen, "_alpha", Regular.easeInOut, 0, 100,
            > _global.FadeInTime, true);
            > Animation.onMotionFinished = function() {
            > tl.nextFrame();
            > };
            >
            >
            > FRAME 2 ACTIONSCRIPT:
            >
            > stop();
            > var myInterval:Number;
            > clearInterval(myInterval);
            > myInterval = setInterval(wait, 4000);
            > function wait() {
            > clearInterval(myInterval);
            > tl.play();
            > }
            >
            • 3. Re: Pause for a few seconds (k)
              kglad Adobe Community Professional & MVP
              you're welcome.

              the timeline that contains that code will advance from frame 1 to 2 to 3. if you want to advance some other timeline, use a reference to that timeline instead of tl (=this).
              • 4. Re: Pause for a few seconds (k)
                Level 7
                This code, when placed on Frame 2, works to pause for 4 seconds on that
                frame:

                //
                startTime = getTimer();
                trace("startTime "+startTime);
                this.onEnterFrame = function() {
                currentTime = getTimer();
                //4000 below = 4 seconds
                if (currentTime-startTime>4000) {
                nextFrame();
                trace("currentTime "+currentTime);
                }
                };


                Problem is that since the currentTime continues to grab the getTimer so
                that if statement is constantly true. So it keeps going from nextFrame
                to nextFrame to nextFrame.

                How can I stop currentTime from grabbing getTimer after 4seconds?

                -Kirk




                kglad wrote:
                > you're welcome.
                >
                > the timeline that contains that code will advance from frame 1 to 2 to 3. if you want to advance some other timeline, use a reference to that timeline instead of tl (=this).
                • 5. Re: Pause for a few seconds (k)
                  kglad Adobe Community Professional & MVP
                  delete your onEnterFrame function.