# setChildIndex of nested mc

**URL:** <https://forum.kirupa.com/t/setchildindex-of-nested-mc/328359>\
**Category:** flash\
**Created:** [May 10, 2012, 4:10pm UTC](https://forum.kirupa.com/t/setchildindex-of-nested-mc/328359 "2012-05-10T16:10:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonassus](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bonassus](https://forum.kirupa.com/u/bonassus)\
**Post date:** [May 10, 2012, 4:10pm UTC](https://forum.kirupa.com/t/setchildindex-of-nested-mc/328359/1 "2012-05-10T16:10:13Z")

</div>

I have an mc on the stage named mcOnStage inside of this mc is another mc named mcInside. I have an mc in the library with a linkage class name of TestMc. I want to instantiate TestMc and then use setChildIndex to put mcInside on top of testMc. This doesn’t work, I get Error #2025: The supplied DisplayObject must be a child of the caller.

```auto
    public class Test extends MovieClip {
        
        private var testmc:TestMc;
        public function Test() {

            testmc = new TestMc;
            addChild(testmc);
    
            this.setChildIndex(mcOnStage.mcInside, this.numChildren - 1);
        }
    }

```

is there a was to achieve this? what am i doing wrong.

help is much appreciated.

Thank you
