Bringing objects of 3d array to front

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;
    }
    ...

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?

How can I do that?

1 Like

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

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

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