2 Replies Latest reply on Sep 10, 2006 9:51 AM by kglad

    multiple functions using var arrays?

      The attached code works perfectly fine but I was wondering is there a better way to write this rather than such repetative code?

        • 1. Re: multiple functions using var arrays?
          scsherwood
          You can write functions for the repetitive code using the access operator, "[ ]", to access the various tabs and rows with variables as follows:

          i = 4; // the tab value, which you will determine from a variable passed to function
          j = 1; // the row value, which I assume you can derive from the tab value

          this["tab" + i + "ON_mc]["tab" + i + "Row" + j + "_mc"]["_alpha"] = 0

          I'm not at my computer with flash loaded on it, so I can't verify I have the syntax exactly correct, but if you experiment with it, you can figure it out. Check out the documentation for the "eval()" function for some help.

          ONce you get the correct syntax down, you can programatically determine the tabs and decide via "i" and "j" what to do with them. Then, set up the function with an argument to pass the tab to be operated on into the function.

          Then all you have to do is reuse the function each time rather than retyping the code.

          Renaming your MovieClips a little bit might make it easier to code (e.g. tabON1, tabOFF1). Leave off the "_mc". Then, to access the movie clip all you have to do is:

          this["tabOFF" + i] or _root["tabOFF" + i]

          Hope this helps.
          • 2. Re: multiple functions using var arrays?
            kglad Adobe Community Professional & MVP
            there may be typos in the code below, but it should give you an idea of the way your code could be condensed: