# \[MX2004\] 2-dimensional array problem

**URL:** <https://forum.kirupa.com/t/mx2004-2-dimensional-array-problem/174885>\
**Category:** flash\
**Created:** [January 10, 2006, 2:01am UTC](https://forum.kirupa.com/t/mx2004-2-dimensional-array-problem/174885 "2006-01-10T02:01:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![watcher](https://avatars.discourse-cdn.com/v4/letter/w/77aa72/32.png) [@watcher](https://forum.kirupa.com/u/watcher)\
**Post date:** [January 10, 2006, 2:01am UTC](https://forum.kirupa.com/t/mx2004-2-dimensional-array-problem/174885/1 "2006-01-10T02:01:04Z")

</div>

Hello,

i have a STRANGE problem with 2d arrays in flash. Trying to create matrix of squares, i used this code:

```auto
var nCol:Number = 8;
var nRows:Number = 6;
var nBlockW:Number = 100; // _width and _height size of block in pixels

var aArray:Array = [[],[]]; // 2-dimensional array declaration
    
for(var i=0; i<nCol; i++){
    for(var j=0; j<nRows; j++){
        var mc = this.attachMovie("mcBlock", "mcBlock_"+i+"_"+j, this.getNextHighestDepth(),{_x:i*nBlockW, _y:j*nBlockW});
        aArray*[j] = mc; // store path to block mc in array
        trace(aArray*[j]) // trace stored
    }
}

```

Now what happens is, that all mcs get properly attached, and displayed BUT array is incorrectly filled: trace(aArray\*[j]) traces:

```auto
_level0.mcMask.mcBlock_0_0
_level0.mcMask.mcBlock_0_1
_level0.mcMask.mcBlock_0_2
_level0.mcMask.mcBlock_0_3
_level0.mcMask.mcBlock_0_4
_level0.mcMask.mcBlock_0_5
_level0.mcMask.mcBlock_1_0
_level0.mcMask.mcBlock_1_1
_level0.mcMask.mcBlock_1_2
_level0.mcMask.mcBlock_1_3
_level0.mcMask.mcBlock_1_4
_level0.mcMask.mcBlock_1_5
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined

```

🙂 sorry for the flood. So as you can see, first 2 iterations of “higher” cycle mc creation are nicely stored, while the rest is not so lucky.

Any ideas how to fix this? Thank you.
