8 Replies Latest reply on Jul 9, 2009 3:10 PM by shintashi

    question about multidimensional array

    shintashi Level 1



      I'm trying to figure out how to generate an array whose elements are each arrays to make a quick loading database of sorts.

      the main array could essentially be something like "employees" while each employee would have demographic data like age, salary, gender, etc.

      In some cases the information on some employees would be greater than others, and options created by "push" would imply the number of

      elements within each employee array would be variable until generated.


      I noticed the multidimensional array setup


      array = new array (new array("A","B"), new array("C","D"));


      and accessed by using




      But I get the feeling this type of array as it is currently described doesn't lend itself well to adding new elements in the way I've described.


      My goal is once an employee's information has been entered and saved, I can call up their info by array number like aEmployee[2], and if employee 2's name is Bob, then Bob's name would appear in the text field, along with all the other fields related to Bob's array, such as being male, 42 years old, and living in Witchita Kansas.


      Would I modify a multidimensional array, or do I want an array within an array, and is there a way to add "arrays" as elements?

        • 1. Re: question about multidimensional array
          kglad Adobe Community Professional & MVP

          for storing information that's not the same across all employees use an object to store employee data and use an array to store all employee objects:


          var eObj:Object={name:"whatever" age:"whatever ssn:"whatever"};


          var eA:Array = [];



          1 person found this helpful
          • 2. Re: question about multidimensional array
            shintashi Level 1

            being terrible with objects, I began working on a model and this is what I came up with

            (for sake of reference namaewa = height, shinchyou = height, omosa = weight)



            shelley = {namaewa: "Shelley", shinchyou: 68, omosa: 132, sex: "F"};


            //if(1 == 1){shelley.takai = 56;}


            //trace(shelley.namaewa +" "+ shelley.sex);


            var peopleA:Array =[];
            peopleA[0] = shelley;





            Most of it works fine, however

            the last line: trace(peopleA[0]);


            spits out [object Object]

            and I have no clue what that means.
            How would I access the material in element 0 (or any other element) so I could display name, height, weight, etc. in dynamic textfields?


            it is my understanding that an object is a container filled with a number of variables and/or functions, with those variables addressed by the

            objectname.variabletype and functions called by typing objectname.function();




            The following experiment rendered several textfields "undefined" but it may explain what I was trying to do:


            function createfile(person){
                    person = {namaewa: "John Doe", shinchyou: 72, omosa: 180, sex: "M"}


                newfile.onRelease = function(){
                filename.text = person.namaewa;
                fileht.text = person.shinchyou;
                filewt.text = person.omosa;
                filesex.text = person.sex;

            • 3. Re: question about multidimensional array
              kglad Adobe Community Professional & MVP

              to list all the data in peopleA[0]:


              for(var s:String in peopleA[0]){

              trace(s+": "+peopleA[0][s]);



              to reference namaewa of peopleA[0]: