# Senocular - Approach to Depth Sorting

**URL:** <https://forum.kirupa.com/t/senocular-approach-to-depth-sorting/272860>\
**Category:** flash\
**Created:** [October 8, 2008, 10:36pm UTC](https://forum.kirupa.com/t/senocular-approach-to-depth-sorting/272860 "2008-10-08T22:36:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danoprey](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@danoprey](https://forum.kirupa.com/u/danoprey)\
**Post date:** [October 8, 2008, 10:36pm UTC](https://forum.kirupa.com/t/senocular-approach-to-depth-sorting/272860/1 "2008-10-08T22:36:41Z")

</div>

Hi, this is a question regarding [Senocular’s Approach to Depth Sorting](http://www.kirupa.com/forum/showthread.php?p=1897023) tip of the day, but anyone is very welcome to answer it!

I am trying to use his code:

> var sortedItems:Array = new Array(mc1, mc2, mc3);  
> function arrange():void {  
> sortedItems.sortOn(“y”, Array.NUMERIC);  
> var i:int = sortedItems.length;  
> while(i–){  
> if (getChildAt(i) != sortedItems\*) {  
> setChildIndex(sortedItems\*, i);  
> }  
> }  
> }

To automatically sort the depths of my objects depending on their y position. To my delight, this worked. But I have a problem. For some reason the objects I apply it to stop being animated (which defeats the point).

E.G. I have two objects, one stationary (stat\_mc), one moving (move\_mc). When move\_mc moves up over stat\_mc it should go behind it when move\_mc’s y position is less than stat\_mc’s. However, this code seems to stop move\_mc from moving!

I can’t understand what is in this code which is causing this.

Thank you so much for any help.
