# Simple ChangeDepths problem, but Hard for Me

**URL:** <https://forum.kirupa.com/t/simple-changedepths-problem-but-hard-for-me/290807>\
**Category:** flash\
**Created:** [June 19, 2009, 8:33pm UTC](https://forum.kirupa.com/t/simple-changedepths-problem-but-hard-for-me/290807 "2009-06-19T20:33:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rooterman42](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@rooterman42](https://forum.kirupa.com/u/rooterman42)\
**Post date:** [June 19, 2009, 8:33pm UTC](https://forum.kirupa.com/t/simple-changedepths-problem-but-hard-for-me/290807/1 "2009-06-19T20:33:18Z")

</div>

Hi,

I’m trying to apply a ChangeDepths() to a bunch movieclips that I’ve nested inside a main movieclip which I’m using as a mask. The ChangeDepths() function worked fine when the clips were not nested, but after I placed them in a new movieclip, I get this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  
at flash.display::DisplayObjectContainer/setChildIndex()  
at test10\_fla::MainTimeline/ChangeDepths()

Here is my code:

// create mask shape  
var maskShape:Shape = new Shape();

```
maskShape.graphics.beginFill( 0xff0000 );
maskShape.graphics.drawRect( 20, 20, 970, 241 );

```

addChild(maskShape);

// create mask container, then add my movieclips to use ChangeDepths() on rollover  
var maskContainer:MovieClip = new MovieClip;

```
maskContainer.x = 0;
maskContainer.y = 0;
maskContainer.mask = maskShape;

addChild( maskContainer );

    maskContainer.addChild( person1_mc );
    maskContainer.addChild( person2_mc );
    maskContainer.addChild( person3_mc );
    maskContainer.addChild( person4_mc );
    maskContainer.addChild( person5_mc );
    maskContainer.addChild( person6_mc );

```

// change depths on rollover  
function ChangeDepths( event:MouseEvent ):void  
{  
var button:MovieClip = event.target as MovieClip;

```
setChildIndex( button, numChildren - 1 );

```

}

Any help would be greatly appreciated!!!

r
