3 Replies Latest reply on Jan 18, 2011 2:41 PM by Ned Murphy

    functions ???

    dannyb89 Level 1

      below is some code i am using to rewind / play an animaion depending on the rollover state. only ting is i would like to have it so that i could do something like:

       

      playFrames(homeBtn)...

       

      this way i can use the same function over and over but i am not sure how to write this. i think its someting like function playFrames(obj); and then you do something with this...

       

      //Home Button //////////////////////////////
      homeBtn.onRollOver = function() {
          playFrames(){
          }
      homeBtn.onRollOut = function() {
          rewindFrames();
      }
      function playFrames(){
      onEnterFrame = function () {
              if (_currentframe<15) {
                  nextFrame();
              } else {
                  delete this.onEnterFrame;
              }
          };
      };
      function rewindFrames(){
          onEnterFrame = function () {
              if (homeBtn._currentframe>1) {
                  homeBtn.prevFrame();
              } else {
                  delete this.onEnterFrame;
              }
          };
      };

        • 1. Re: functions ???
          Ned Murphy Adobe Community Professional & MVP

          If you mean you want the buttons themselves to animate using a shared function, the following should work...

           

          homeBtn.onRollOver = otherBtn.onRollOver = function() {
              playFrames(this);
          }

           
          homeBtn.onRollOut = otherBtn.onRollOut = function() {
              rewindFrames(this);
          }

           

          function playFrames(btn){
          onEnterFrame = function () {
                  if (btn._currentframe<15) {
                      btn.nextFrame();
                  } else {
                      delete this.onEnterFrame;
                  }
              }
          }

           
          function rewindFrames(btn){
              onEnterFrame = function () {
                  if (btn._currentframe>1) {
                      btn.prevFrame();
                  } else {
                      delete this.onEnterFrame;
                  }
              }
          }

          • 2. Re: functions ???
            dannyb89 Level 1

            Thanks mate

             

            Sent from my iPhone

            • 3. Re: functions ???
              Ned Murphy Adobe Community Professional & MVP

              You're welcome