1 Reply Latest reply on Jul 23, 2007 4:10 PM by Newsgroup_User

    Applying same function to multiple buttons

    BillG-Seattle Level 1
      I have a series of buttons for which I want to apply the same function. For example:

      btn1.onRollOver = function() {
      this.tabBtn.gotoAndStop("over");
      };
      btn2.onRollOver = function() {
      this.tabBtn.gotoAndStop("over");
      };

      My question is...how can I call the same function from multiple buttons, without repeating this same code over and over?
        • 1. Re: Applying same function to multiple buttons
          Level 7
          Hi,

          function generic(){
          // do whatever is needed
          }

          btn1.onRollOver = generic;
          btn2.onRollOver = generic;

          would do the trick.


          BillG-Chicago wrote:
          > I have a series of buttons for which I want to apply the same function. For
          > example:
          >
          > btn1.onRollOver = function() {
          > this.tabBtn.gotoAndStop("over");
          > };
          > btn2.onRollOver = function() {
          > this.tabBtn.gotoAndStop("over");
          > };
          >
          > My question is...how can I call the same function from multiple buttons,
          > without repeating this same code over and over?
          >

          --
          ----------
          Manno Bult
          http://www.aloft.nl