4 Replies Latest reply on Aug 1, 2007 9:51 AM by kglad

    Movie Clips Simple Control

    Jens1701
      Hello Folks,
      i want to learn how to use Actionsscript 3.
      As practice i tried to build the controls Play, Stop, Rewind, FF and Jump for a simple tween with no continous loop.
      But soon i got stuck with the rewind function. The ENTER_FRAME Event that is needed for an automatic rewind interfere with the rest of the functions. I think the problem is that the ENTER_FRAME EventListener is active from the beginning, but it should be only active if rewind is active.
      I got the Idea for the rewind from http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm
      Chapter: Programming ActionScript 3.0/Working with movie clips

      My Script so far:

      //Let not start the animation automaticly.
      box_mc.stop();

      //Eventlistener for the Buttons. Over!
      play_btn.addEventListener(MouseEvent.MOUSE_OVER, playAnimation);
      rewind_btn.addEventListener(MouseEvent.MOUSE_OVER, rewindAnimation);

      //EventListener for the Buttons. Out!
      play_btn.addEventListener(MouseEvent.MOUSE_OUT, playAnimation);
      rewind_btn.addEventListener(MouseEvent.MOUSE_OUT, rewindAnimation);

      //Eventlistener for a continious rewind
      box_mc.addEventListener(Event.ENTER_FRAME, rewindAnimation);

      // Function for the Play Button. Stops at the last frame.
      function playAnimation(event:MouseEvent):void {
      box_mc.play();
      if(box_mc.currentFrame == totalFrames){
      box_mc.stop();
      }
      }
      // Function for the Rewind Button. Stops at the first frame.
      function rewindAnimation(event:MouseEvent):void {
      box_mc.prevFrame();
      }

      So all tips getting around this are welcome.

      Thank you.
        • 1. Re: Movie Clips Simple Control
          Jens1701 Level 1
          I forgot: The animation is inside a Symbol. Inside the Symbol the timeline got 40 Frames.
          Scene 1 the timeline got 1 frame.
          Layers: Buttons for the buttons
          Tween for the animation
          and Action for the Script
          • 2. Re: Movie Clips Simple Control
            kglad Adobe Community Professional & MVP
            add your enter_frame listener in your rewindAnimation() function and remove it when frame 1 is reached.

            addendum: move your prevFrame() method to a function that your enter_frame listener calls.
            • 3. Re: Movie Clips Simple Control
              Jens1701 Level 1
              many thx
              that worked out! :)

              //Let not start the animation automaticly.
              box_mc.stop();

              //Eventlistener for the Buttons. Over!
              play_btn.addEventListener(MouseEvent.MOUSE_OVER, playAnimation);
              rewind_btn.addEventListener(MouseEvent.MOUSE_OVER, rewindAnimation);
              //EventListener for the Buttons. Out!
              play_btn.addEventListener(MouseEvent.MOUSE_OUT, stopAnimation);
              rewind_btn.addEventListener(MouseEvent.MOUSE_OUT, stopAnimation);


              // function for the Play Button. Mouse_Over
              function playAnimation(event:MouseEvent):void {
              if (box_mc.currentFrame != box_mc.totalFrames) {
              box_mc.play();
              }
              box_mc.addEventListener(Event.ENTER_FRAME, stopAtLastFrame);
              }
              // function for the Rewind Button. Mouse_Over
              function rewindAnimation(event:MouseEvent):void {
              box_mc.addEventListener(Event.ENTER_FRAME, oneFrameBack);
              }
              // function for stopping. Mouse.out
              function stopAnimation(event:MouseEvent):void {
              box_mc.stop();
              box_mc.removeEventListener(Event.ENTER_FRAME, oneFrameBack);
              }


              // function for Stoppimg at the last frame
              function stopAtLastFrame(event:Event) {
              if (box_mc.currentFrame == box_mc.totalFrames) {
              box_mc.stop();
              box_mc.removeEventListener(Event.ENTER_FRAME, stopAtLastFrame);
              }
              }
              //function for going one frame back
              function oneFrameBack(event:Event):void {
              if (box_mc.currentFrame == 1) {
              box_mc.removeEventListener(Event.ENTER_FRAME, oneFrameBack);
              } else {
              box_mc.prevFrame();
              }
              }
              • 4. Re: Movie Clips Simple Control
                kglad Adobe Community Professional & MVP
                you're welcome.