2 Replies Latest reply on Mar 4, 2009 3:51 AM by Newsgroup_User

    accessing array

    rahimhaji Level 1
      Dear Friends,

      i have a set of arrays like:
      chk1 = [1,2,3,4,5]
      chk2 = [a,b,c,d,e]
      chk3 = [f,g,h,j,k]

      in programatically i want to access chk1[2], which is chk1[2] = 3. How can i write? i have the variable names for 1 & 2 that is chk + variablename1 +[+variablename2+] = ? . pls help me to find way to mention this.

      here in as3 and flex we dont have eval also. in AS 3 i can use this option for object. but for array i dont know how to use. pls help me to refer the array elements.

      Thanks and Regards,
      Syed Abdul Rahim
        • 1. Re: accessing array
          atta707 Level 2

          chk + variablename1 +[+variablename2+]

          won't work. You can instead have a double dimensional array:

          var chk:Array = new Array();

          chk[0][2] should give you 3!

          I hope this helps.

          • 2. Re: accessing array
            Level 7
            Since objects are just associative hashes, you can also do this by using:


            But in this case, since the different arrays are obviously closely
            related, I would suggest following ATTA's advice and using
            multi-dimensional arrays.