Link to home
Start Free TrialLog in
Avatar of gdejarnett
gdejarnett

asked on

Declaring a multidimensional associative array in Flash 8 actionscript.

In Flash 8 I need to have a 2-dimensional associative array available to be populated with a variable amount of data coming from my server.  Here is how I have it declared:

line = new Array(new Array(new Array(2)));

To experiment with my definition, I used the following code:

line[0][0].address = "first address";
line[0][0].zip = "first zip";
line[0][1].address = "second address";
line[0][1].zip = "second zip";
line[1][0].address = "third address";
line[1][0].zip = "third zip";

for (i in line){
      for (j in line[i]){
            trace("inside "+j);
            trace("address  = " +line[i][j].address);
            trace("zip = " +line[i][j].zip);
      }
}

Here is the trace output:

inside 0
address  = first address
zip = first zip

Why is only the first pair of the first line being populated?  Is it possible for me to define this in such a way that I may have a variable number of address/zip pairs for each line as well as a variable number of lines?

Thanks.

ASKER CERTIFIED SOLUTION
Avatar of DiscoNova
DiscoNova
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdejarnett
gdejarnett

ASKER

Thanks DiscoNova,
You are right, I was confusing object and arrays.