3 Replies Latest reply on Nov 12, 2010 6:54 AM by Graham vdR

    How to create unique variables in for loops? (AS2)

    Graham vdR Level 1

      Hi there


      I'm wondering if it's possible to create variables in a for loop that uses an incrementing number in the variable name.


      This is the code I've tried (as a long shot) but isn't working:



      var i:Number;
      for(i = 1; i < 10; i++){
          var ["number" + String(i)]:Number = i;





      What I'm trying to create here is a series of variables called "number1", "number2", "number3", etc. Is there another way of doing it? I'd need them to be public (I think that's the term?), so they can be used elsewhere in the script.


      I'd appreciate any advice.