# Creating/populating a 2d/multidimensional array

**URL:** <https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057>\
**Category:** Uncategorized\
**Created:** [April 10, 2006, 4:43pm UTC](https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057 "2006-04-10T16:43:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Operator](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/operator/32/2182_2.png) [@Operator](https://forum.kirupa.com/u/Operator)\
**Post date:** [April 10, 2006, 4:43pm UTC](https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057/1 "2006-04-10T16:43:29Z")

</div>

I suppose this is an easy question but I can’t seem to get it to work.  
How does one create and populate a 2d array in flash?

I am first defining the array with:

```auto
some_array = [],[];

```

and then im populating it with xml data with a loop like this:

```auto
for (c=0; c<5; c++) {
some_array[i,c] = xmlNode.childNodes*.firstChild.nodeValue;
            }

```

please assume that this code exists in another for loop which loops i  
also please assume that 5 is my total list of entries in the xml file  
i simplified my code for posting.  
i just want to know what the proper synax is for populating this 2d array.  
also how do i access it? array [i,c]?

right now whats happening is the array does fill up but only with the last values. so obviously something isnt right.

---

<div class="post-metadata">

**Author:** ![Operator](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/operator/32/2182_2.png) [@Operator](https://forum.kirupa.com/u/Operator)\
**Post date:** [April 10, 2006, 5:11pm UTC](https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057/2 "2006-04-10T17:11:25Z")

</div>

hmm ok nevermind. i think i got it. i used this guy EliteMX’s code which I found here:  
[http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs\_Parts&file=Part4\_ASLR2.html](http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=Part4_ASLR2.html)  
good luck to anyone doing this 🙂

---

<div class="post-metadata">

**Author:** ![Operator](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/operator/32/2182_2.png) [@Operator](https://forum.kirupa.com/u/Operator)\
**Post date:** [April 11, 2006, 6:01pm UTC](https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057/3 "2006-04-11T18:01:17Z")

</div>

you know, it seems as though this code is flawed after-all.  
it works, in that the array does get populated, but im having a problem pulling data from it for use in a transitions.easing call…

so once again, i ask, what is the proper way to define, populate, and call a 2d array in actionscript?

---

<div class="post-metadata">

**Author:** ![devinstar](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@devinstar](https://forum.kirupa.com/u/devinstar)\
**Post date:** [April 11, 2006, 6:31pm UTC](https://forum.kirupa.com/t/creating-populating-a-2d-multidimensional-array/185057/4 "2006-04-11T18:31:24Z")

</div>

myArray = new Array();

for(i=0;i\<20;i++){  
myArray\* = “variable”;  
}

use ctrl+shift+enter to publish the .swf in debug mode then you can check how your array has been populated by pressing the play button (to play the movie, dah!) then click \_level0 (root) or wherever the array is stored. Then click the Variables tab you should see the name of the array then click the “+” icon and you will be able see what values your array has.

phew hope that helps!
