# Depth Management: I hate feeling stupid

**URL:** <https://forum.kirupa.com/t/depth-management-i-hate-feeling-stupid/271318>\
**Category:** Uncategorized\
**Created:** [September 21, 2008, 3:47pm UTC](https://forum.kirupa.com/t/depth-management-i-hate-feeling-stupid/271318 "2008-09-21T15:47:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![8Up](https://avatars.discourse-cdn.com/v4/letter/8/e47c2d/32.png) [@8Up](https://forum.kirupa.com/u/8Up)\
**Post date:** [September 21, 2008, 3:47pm UTC](https://forum.kirupa.com/t/depth-management-i-hate-feeling-stupid/271318/1 "2008-09-21T15:47:35Z")

</div>

Preface: I’m very new to AS3. I had a project thrust upon me because I’m supposedly a “bright and resourceful guy.” AS3 for the uninitiated (Read: me) is akin to writing Mandarin Chinese upside down and backwards- with my left hand- while looking at the text in the mirror of a moving SUV going off-roading.

I’ve seen this question or some derivative of it posed many times so a) I apologize for the reDUNCE-ancy and b) I will try to be concise.

**Situation:** I have 68 movieclip buttons on the stage simultaneously. I need for the active/selected clip to be at the uppermost level so that it plays in front/ on top of the surrounding clips.

I found, copied, and modified the simple code below to test on 3 simple clips (Square1, Circle1, Triangle1).

this.addEventListener(MouseEvent.MOUSE\_OVER, swapd, false, 0, true);

function swapd(evt:MouseEvent):void {  
var Square1:MovieClip = evt.target as MovieClip;  
var Circle1:MovieClip = evt.target as MovieClip;  
var Triangle1:MovieClip = evt.target as MovieClip;

setChildIndex(Square1, numChildren - 1);  
setChildIndex(Circle1, numChildren - 1);  
setChildIndex(Triangle1, numChildren - 1);

Square1.buttonMode=true  
Circle1.buttonMode=true  
Triangle1.buttonMode=true

}  
Square1.addEventListener(MouseEvent.MOUSE\_DOWN,go)  
function go (evt:MouseEvent):void {  
Square1.gotoAndPlay(1);  
}  
Circle1.addEventListener(MouseEvent.MOUSE\_DOWN,go2)  
function go2 (evt:MouseEvent):void {  
Circle1.gotoAndPlay(1);  
}

These simple clips contain only shapes/fills with shape tweens. It works fine so long as the clips do not contain any _other_ clips/buttons. Placing even a simple button within any of these clips rewards me with

“ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.”

\*\*Problem: \*\*I need to have each of the 68 movieclips actually contain other clips, buttons, etc and not just shape/shape tweens. I’ve found the “solution” to this problem dozens of times on various forums but because I can barely speak the language (Read: Mandarin Chinese) the answer still eludes me.

I am developing a basic understanding of the underlying concepts, tools, and mechanics of AS3 but that’s the same as having a basic understanding of an unassembled bike on Christmas Eve and limited knowledge of what a screwdriver actually does. It’s almost morning and I’m still reading the assembly instructions…
