# Swap Depths Between Root and Nested MCs

**URL:** <https://forum.kirupa.com/t/swap-depths-between-root-and-nested-mcs/308471>\
**Category:** flash\
**Created:** [April 23, 2010, 2:12pm UTC](https://forum.kirupa.com/t/swap-depths-between-root-and-nested-mcs/308471 "2010-04-23T14:12:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jephz](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@Jephz](https://forum.kirupa.com/u/Jephz)\
**Post date:** [April 23, 2010, 2:12pm UTC](https://forum.kirupa.com/t/swap-depths-between-root-and-nested-mcs/308471/1 "2010-04-23T14:12:52Z")

</div>

Hi everyone, this is my first time working with depths, so bare with me.

I’ve realized that I am unable to swap depths between \_root. and nested mc’s based on its \_y axis.

For example, I use this code:

```auto

_root.player.onEnterFrame =function() {
	this.swapDepths(this._y-230)
	_root.objectHolder.object1.swapDepths(_root.objectHolder.object1._y) //nested movieclip
	_root.object2.swapDepths(_root.object2._y-230); // _root. movieclip
	if(Key.isDown(Key.RIGHT)) {
		this._x += 3
	}
	if(Key.isDown(Key.LEFT)) {
		this._x -= 3
	}
	if(Key.isDown(Key.UP)) {
		this._y -= 3
	}
	if(Key.isDown(Key.DOWN)) {
		this._y +=3
	}
}

```

The one in \_root. swaps, but the nested one doesn’t. I’ve already tweaked the depths so that the nested depths and the \_root. depths match, since the nested mc is lower then the \_root.

But it still doesn’t work…any help is greatly appreciated.

PS: Please view [this SWF file for a better understanding. FLA is available [URL=“[http://spamtheweb.com/ul/upload/230410/79884\_depthIssue.fla](http://spamtheweb.com/ul/upload/230410/79884_depthIssue.fla)”]here](http:// [http://spamtheweb.com/ul/upload/230410/79498\_depthIssue.php](http://spamtheweb.com/ul/upload/230410/79498_depthIssue.php)) too (I’m on a Mac, so no viruses)

-Jephz
