3 Replies Latest reply on Aug 4, 2007 12:52 PM by kglad

    various problems with multidimensional arrays

    bonions
      HI, im hoping someone can help me out with a few problems with multi dimensional arrays. Ive tried looking everywhere but just cant seem to find a clear answer
      im in flash mx.

      first problem:

      im creating 2arrays
      ddp = new Array();
      dap = new Array();

      that im putting into a combined multi dimensional array
      dp = new Array();

      by doing it this way
      dp[k] = "["+ddp[k]+"]["+dap[k]+"]";

      i can pull out one section fine eg : dp[k] = [27.905][234.2594]

      but cannot seem to get the answer 234.2594, or dp[1][1] or any other way i can think of, just doesnt seem to pul out the subsection i need,
      what am i doing wrong here?


      Second problem, :
      i need to create dynamically named arrays but cannot seem to get it to initialise or anything..

      eg: i have variables ( all with various 'changing' counts and do not know the total until the array needs to be created) eg : p1, p2,p3,p4

      and need to create arrays to match eg p1=new Array();
      but the 1 in p1 changes each pass so its "p"+count=new Array(),
      but thats not creating the array or working, nor is any way of trying to get round not having "p"+count before the '=new Array()' bit.

      i hope that makes sense as im at a complete loss
      many thanks
      shane
        • 1. Re: various problems with multidimensional arrays
          kglad Adobe Community Professional & MVP
          1. your problem is the way you're defining dp[k]: it's a string. it may look like two juxtaposed array elements to you, but that's not what it looks like to flash.

          2. if you want to define your arrays on the current timeline use:

          • 2. Re: various problems with multidimensional arrays
            bonions Level 1
            many thanks Kglad, i have the dynamic name working now,

            .. but im still a little sketchy about getting the answer from the multi dimensional array problem. ( the dp[k][1] bit of original post )
            is there a way to build the multi dimensional array so that i can call the variable i want easily ?..
            i want to set it up so that i have something like this:

            variable 1 - has 2 answers, answer 1 and answer 2
            variable 2 - has answer 1 and answer 2 and so on...

            (with all the answer being numbers only)

            and im thinking in the multi array it will be laid out somethign like this
            doublearray=new Array( [variable1answer1][variable1anser2] , [variable2answer1][variable2answer2])

            but i want to call the answers seperatly after i have decided what variable i want..
            eg myarray[variable1][answer2]= to give me just the resulting answer i want
            many thanks again for the help so far
            shane
            • 3. Re: various problems with multidimensional arrays
              kglad Adobe Community Professional & MVP
              after declaring dp is an array: