# Swap depth

**URL:** https://forum.kirupa.com/t/swap-depth/53461
**Category:** Uncategorized
**Created:** [June 4, 2004, 12:19am UTC](https://forum.kirupa.com/t/swap-depth/53461 "2004-06-04T00:19:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![z3r0](https://avatars.discourse-cdn.com/v4/letter/z/cdc98d/32.png) [@z3r0](https://forum.kirupa.com/u/z3r0)
#### Post date: [June 4, 2004, 12:19am UTC](https://forum.kirupa.com/t/swap-depth/53461/1 "2004-06-04T00:19:36Z")

</div>

Can someone please tell me why this swapdepths doesn’t work?

heres the fla

[http://www.soccerschool.com.ar/f/swap.zip](http://www.soccerschool.com.ar/f/swap.zip)

Here’s the code:

```auto

//Action attached to frame 1

function depthSwap (x) {
	for (i=0; i<cA.length; i++) {
		if (cA* == x) {
			xPos = i;
		}
	}
	i = xPos;
	for (i=xPos; i>0; i--) {
		_root[x].swapDepths(_root[cA*]);
		cA* = cA[i-1];
	}
	_root[x].swapDepths(_root[cA[0]]);
	cA[0] = x;
}
cA = new Array();
for (i=0; i<7; i++) {
	cA* = "c"+i;
}

//Action on the movieclip called c1 - the same on the other called c2 - 

onClipEvent (mouseMove) {
		if (this.hitTest(_root._xmouse, _root._ymouse, false));
{	_root.status = ( hitTest(_root._xmouse, _root._ymouse, false));
_root.depthSwap(this._name);
	}
	}

```
