# Evil swapDepths

**URL:** <https://forum.kirupa.com/t/evil-swapdepths/218430>\
**Category:** Uncategorized\
**Created:** [March 7, 2007, 6:20pm UTC](https://forum.kirupa.com/t/evil-swapdepths/218430 "2007-03-07T18:20:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpoint](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bpoint/32/3419_2.png) [@bpoint](https://forum.kirupa.com/u/bpoint)\
**Post date:** [March 7, 2007, 6:20pm UTC](https://forum.kirupa.com/t/evil-swapdepths/218430/1 "2007-03-07T18:20:45Z")

</div>

Hello all,

I’m new to these forums and was going to ask a question as to why the following code did absolutely nothing:

```auto

a = _root.createEmptyMovieClip("", _root.getNextHighestDepth());
b = _root.createEmptyMovieClip("", _root.getNextHighestDepth());
ad = a.getDepth();
bd = b.getDepth();
trace("a depth: " + ad);
trace("b depth: " + bd);
b.swapDepths(ad - 1);
ad = a.getDepth();
bd = b.getDepth();
trace("a depth: " + ad);
trace("b depth: " + bd);

```

If you run this, you’ll notice that swapDepths does absolutely nothing, and prints the following:

```auto

a depth: 0
b depth: 1
a depth: 0
b depth: 1

```

I’d been searching Google for over 3 hours now, reading Adobe’s crappy documentation and tutorials everywhere (that’s what made me register here), but as I was waiting for the account activation mail to arrive, I wondered if perhaps the fact my MovieClips were unnamed was what was causing the problem…

So I gave it a try:

```auto

a = _root.createEmptyMovieClip("a", _root.getNextHighestDepth());
b = _root.createEmptyMovieClip("b", _root.getNextHighestDepth());

```

And what do you know?

```auto

a depth: 0
b depth: 1
a depth: 0
b depth: -1

```

Argh!!! _pulls hair out_

Well, if this helps anyone else out there trying to figure out why swapDepths is being braindead, then I’m glad I helped. 🙂
