# Bringing objects of 3d array to front

**URL:** <https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916>\
**Category:** flash\
**Created:** [January 24, 2015, 12:36am UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916 "2015-01-24T00:36:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![onurcan1977](https://avatars.discourse-cdn.com/v4/letter/o/9e8a1a/32.png) [@onurcan1977](https://forum.kirupa.com/u/onurcan1977)\
**Post date:** [January 24, 2015, 12:36am UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/1 "2015-01-24T00:36:49Z")

</div>

I’m trying to create 3d array which holds movieclips and textfields. When I test the movie, textfields aren’t visible, they are behind movieclips (I guess so). I tried using setchildindex however it gave me error. Here’s my code.

```
for (var _x:int = 0; _x <= MAX_X; _x++)
{
    for (var _y:int = 0; _y <= MAX_Y; _y++)
    {
        for (var _z:int = 0; _z <= MAX_Z; _z++)
        {
            if (_z == 0) {
                // Create captions
                var mcCaption:MovieClip = createMc("captionBox", false);

                rowArray[_x][_y][_z] = mcCaption;
                spSource.addChild(rowArray[_x][_y][_z]);
                rowArray[_x][_y][_z].addEventListener(MouseEvent.MOUSE_DOWN, mcCaptionHandler);

                rowArray[_x][_y][_z].x = nextXpos;
                rowArray[_x][_y][_z].name = "beatCaption_" + _x + "_" + _y + "_" + _z;
            } else if (_z == 1) {
                var txt:TextField = new TextField();

                rowArray[_x][_y][_z] = txt;
                rowArray[_x][_y][_z].text = _y;
                rowArray[_x][_y][_z].defaultTextFormat = caption_tf;
                rowArray[_x][_y][_z].setTextFormat(caption_tf);

                spSource.addChild(rowArray[_x][_y][_z]);
                rowArray[_x][_y][_z].addEventListener(MouseEvent.MOUSE_DOWN, mcCaptionHandler);

                rowArray[_x][_y][_z].x = nextXpos;
            }
        }
        nextXpos = nextXpos + newMcWidth;
    }
    ...
```

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [January 24, 2015, 1:06am UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/2 "2015-01-24T01:06:35Z")

</div>

At first glance, it looks like the ordering is correct. If you opt out of addChilding the movieclips altogether, do you see the text then?

---

<div class="post-metadata">

**Author:** ![onurcan1977](https://avatars.discourse-cdn.com/v4/letter/o/9e8a1a/32.png) [@onurcan1977](https://forum.kirupa.com/u/onurcan1977)\
**Post date:** [January 24, 2015, 1:42pm UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/3 "2015-01-24T13:42:38Z")

</div>

How can I do that?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [January 25, 2015, 4:44am UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/4 "2015-01-25T04:44:21Z")

</div>

delete the line of code that uses addChild with your movie clip

---

<div class="post-metadata">

**Author:** ![onurcan1977](https://avatars.discourse-cdn.com/v4/letter/o/9e8a1a/32.png) [@onurcan1977](https://forum.kirupa.com/u/onurcan1977)\
**Post date:** [January 25, 2015, 10:40pm UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/5 "2015-01-25T22:40:16Z")

</div>

Oh I see. I commented out “addchild” and now I can see the textfields.

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [January 26, 2015, 7:40pm UTC](https://forum.kirupa.com/t/bringing-objects-of-3d-array-to-front/491916/6 "2015-01-26T19:40:32Z")

</div>

hmm weird. How about if you switch the adding order. Text in \_z==0 and the movieclip in \_z==1?
