# Can you think of an easy way to convert this to AS3? '3D' Depth swapping

**URL:** https://forum.kirupa.com/t/can-you-think-of-an-easy-way-to-convert-this-to-as3-3d-depth-swapping/266421
**Category:** Uncategorized
**Created:** [July 20, 2008, 4:18am UTC](https://forum.kirupa.com/t/can-you-think-of-an-easy-way-to-convert-this-to-as3-3d-depth-swapping/266421 "2008-07-20T04:18:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)
#### Post date: [July 20, 2008, 4:18am UTC](https://forum.kirupa.com/t/can-you-think-of-an-easy-way-to-convert-this-to-as3-3d-depth-swapping/266421/1 "2008-07-20T04:18:47Z")

</div>

```auto
swapDepths(Math.round(this._xscale) + 100);
//this is for a pseudo-3D effect, the standard cliche carousel.
//It keeps things visually layered properly.

```

… thoughts?

So, I guess the obvious first thing is that \_xscale is now scaleX, but the bigger question is - now that we can’t arbitrarily set things to non-existent depths, this needs to be much more precise.

Ideas? I’m like [—] far from just jamming a bunch of empty sprites in there. 😑

_ **edit:** _ Got it working with the following:

```auto

private function setDepths(e:Event = null):void
{
	_items.sortOn("scaleX", Array.NUMERIC | Array.DESCENDING);
	
	for(var i:int = 0; i < numOfItems; i++)
	{
		setChildIndex(_items*, numOfItems)
	}
}

```
