GoodBoyDigital/pixi.js — pull request #431 by namuol (2013-12-06 05:52:21+00:00)
Title: `swapChildren` implementation

Simplest solution I could think of -- just made use of `addChildAt`:

```javascript
PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
{
if (child === child2) {
return;
}

var index1 = this.children.indexOf(child);
var index2 = this.children.indexOf(child2);

if (index1 < 0 || index2 < 0) {
throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
}

this.removeChild(child);
this.removeChild(child2);

if(index1 < index2)
{
this.addChildAt(child2, index1);
this.addChildAt(child, index2);
}
else
{
this.addChildAt(child, index2);
this.addChildAt(child2, index1);
}
}
```

Here's a simple example:

```html

pixi.js example 1

```