3 Replies Latest reply on Apr 21, 2013 10:57 AM by Ned Murphy

    Play movieClip backwards simulating a combination lock?

    Gargantuan Media

      Hey guys, I want have a movie clip of combination lock dial moving forwards from the letter A to the letter D. I want to create a variable for the current letter and send the animation backwards or forwards based on where the current letter is at. The clip is animated and can't move 1 frame at a time. It has to play backwards.

       

      I am adding links to the files, here:

      FLA (16mb)

      SWF (1mb)

      ZIP (15mb)

       

      I'm working in AS2 Flash CS4.

        • 1. Re: Play movieClip backwards simulating a combination lock?
          Ned Murphy Adobe Community Professional & MVP

          To move backwards on the timeine you can use the prevFrame() function.  To move several frames backwards you can use it in combination with an onEnterFrame function, deleting the onEnetrFrame when you reach whatever _currentframe you intend to stop at.

          1 person found this helpful
          • 2. Re: Play movieClip backwards simulating a combination lock?
            Gargantuan Media Level 1

            Thank you for your advice. I'm afraid that I am very unskilled with AS2. The code below reflects how I have implemented a button that plays a 96 frame movie clip called "windmill_mc" backwards.

             

            this.btn_1.onRelease=function() {

            windmill_mc.onEnterFrame=function(){

            windmill_mc.prevFrame();

            if((windmill_mc._currentframe==1) && (windmill_mc._currentframe==96)){

            delete this.onEnterFrame;

            }

            }

            }

             

            How can I  define a constraint that will stop the button from working if the movie clip is at a certain frame? I have tried to set if statements to "windmill_mc._currentframe < Framenumber" and "windmill_mc._currentframe > Framenumber" but this just loops the clip. Thank you for your assistance.

            • 3. Re: Play movieClip backwards simulating a combination lock?
              Ned Murphy Adobe Community Professional & MVP

              The condition that you have can never be true because you can't be in two places at the same time (frame 1 and frame 96).  Also, if you assign the enterFrame to the windmill, you need to remove it from there as well.  One other thing, avoid nesting functions within other functions whenever possible.

               

              With that said, I would try rewriting the code to not move before checking where things are...

               

              btn_1.onRelease=function() {
                   windmill_mc.onEnterFrame = goBack;
              }

               

              function goBack(){
                  if(windmill_mc._currentframe > 1){
                      windmill_mc.prevFrame();
                  } else {
                      delete windmill_mc.onEnterFrame;
                  }
              }