# swapDepths prototype?

**URL:** https://forum.kirupa.com/t/swapdepths-prototype/77772
**Category:** flash
**Created:** [January 30, 2005, 12:57am UTC](https://forum.kirupa.com/t/swapdepths-prototype/77772 "2005-01-30T00:57:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)
#### Post date: [January 30, 2005, 12:57am UTC](https://forum.kirupa.com/t/swapdepths-prototype/77772/1 "2005-01-30T00:57:44Z")

</div>

Okay so this is from the swapDepths tutorial on kirupa:

```auto
on (press, release, dragOver, dragOut) {
	_root.x +=2;
	_root.green.swapDepths(_root.x);
}

```

and I tried to make it a prototype:

```auto

MovieClip.prototype.swap = function(MC){
_root.x+=2;
_root.MC.swapDepths(_root.x);
}

```

thinking that I could just send whatever movieclip I wanted to the function and it would pop it to the top. But it doesn’t work. ☹ A trace shows the depth to be at the bottom limit (-16843 or whatever it is).

Why is this?

Also - I searched layer51 for an alternative. One only worked if all the MCs were in an array (no thanks). Another one I noticed Senocular had commented on but I didn’t totally understand it:

```auto

//prototype
// Get Function
function getTiefe() {
	return this.getDepth();
}

// Set Function
function setTiefe(nr) {
	swapDepths.call(this, nr);
}

// Addpropery 
MovieClip.prototype.addProperty("_mcDepth", getTiefe, this.setTiefe);

//usage
// Set

clip_mc._mcDepth = 10;

// Get

trace(clip_mc._mcDepth);

```

and Sen’s comment:

> [@Senocular](#):
>
> or more simply
> 
> MovieClip.prototype.addProperty(“\_depth”, getDepth, swapdepths);

but I don’t totally get it.

Can someone explain

1. why my first attempt failed so miserably and/or
2. what does Sen’s suggestion do and how can I use it?

thank yous! :pleased:
