3 Replies Latest reply on May 30, 2006 5:34 AM by Newsgroup_User

    dynamically named arrays?

    Level 7
      Hi

      Is it possible to create arrays on the fly? ie.

      sections = new Array();
      sections[0] = "section1";
      sections[1] = "section2";
      sections[2] = "section3";
      for (x=0;x<sections.length;x++) {
      arraycreator = sections[x];
      arraycreator = new Array();
      }

      P.s. the code above doesnt work!

      Any help appreciated!

      Shaun


        • 1. Re: dynamically named arrays?
          Level 7
          I'm not 100% sure what you are trying to do here. If you are trying to
          create new arrays based on the names in your 'sections' array, try this:

          sections = new Array();
          sections[0] = "section1";
          sections[1] = "section2";
          sections[2] = "section3";
          for (x=0; x<sections.length; x++) {
          arraycreator = sections[x];
          this[arraycreator] = new Array();
          }


          --
          -------------------------------
          Remove '_spamkiller_' to mail
          -------------------------------


          • 2. Re: dynamically named arrays?
            Level 7
            perfect thats what i needed! thanks

            Shaun

            "Peter Blumenthal" <mmgroups@_spamkiller_PhageInteractive.com> wrote in
            message news:e5he1b$7ko$1@forums.macromedia.com...
            > I'm not 100% sure what you are trying to do here. If you are trying to
            > create new arrays based on the names in your 'sections' array, try this:
            >
            > sections = new Array();
            > sections[0] = "section1";
            > sections[1] = "section2";
            > sections[2] = "section3";
            > for (x=0; x<sections.length; x++) {
            > arraycreator = sections[x];
            > this[arraycreator] = new Array();
            > }
            >
            >
            > --
            > -------------------------------
            > Remove '_spamkiller_' to mail
            > -------------------------------
            >
            >


            • 3. Re: dynamically named arrays?
              Level 7
              > perfect thats what i needed! thanks

              Great. You're welcome.

              --
              -------------------------------
              Remove '_spamkiller_' to mail
              -------------------------------