swapDepths prototype?

Okay so this is from the swapDepths tutorial on kirupa:

on (press, release, dragOver, dragOut) {
	_root.x +=2;

and I tried to make it a prototype:

MovieClip.prototype.swap = function(MC){

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. :frowning: 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:

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

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

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

// Set

clip_mc._mcDepth = 10;

// Get


and Sen’s comment:

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: