3 Replies Latest reply on Jun 19, 2009 8:18 AM by keithwoods

    Using a 'for' loop to create similar varibales

    keithwoods Level 1

      Hi there,

      I'm trying to create a number of similar variables using a for loop, rather than having to explicitly write out each variable.

      For instance, I need 9 variables called zone1, zone2, zone3 etc.

      So rather than writing it out like so...

      ActionScript Code:
      public var zone0:Zone = new Zone();
              public var zone1:Zone = new Zone();
              public var zone2:Zone = new Zone();
      // etc. etc.

      After a look around on the internet, I came up with this, however, it doesn't work...

      ActionScript Code:
      for (var i:uint = 0; i<=8; i++)
                          public var this["zone" + i]:Zone = new Zone()

      Any pointers greatly appreciated!