# setChildIndex , issue

**URL:** <https://forum.kirupa.com/t/setchildindex-issue/320086>\
**Category:** flash\
**Created:** [March 13, 2011, 11:13pm UTC](https://forum.kirupa.com/t/setchildindex-issue/320086 "2011-03-13T23:13:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ColinDavies](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@ColinDavies](https://forum.kirupa.com/u/ColinDavies)\
**Post date:** [March 13, 2011, 11:13pm UTC](https://forum.kirupa.com/t/setchildindex-issue/320086/1 "2011-03-13T23:13:11Z")

</div>

I’m trying to set the the index/z order of objectx use the y value as a base,  
: MapObjects i derived from MovieClip  
perspthings is an associated array  
setZOrder the function is called after a mouse event,  
so my code is as follows 1/2 derived from books etc.

```auto
 
 
public function setZOrder():void
{
 
   var perspthingsNum:int = perspThings.length;
   perspThings.sortOn("x", Array.DESCENDING | Array.NUMERIC);
    perspThings.reverse();
 
    for(var i:uint = 0; i < perspthingsNum ; i++)
    {
        var toSortMO:MapObjects = perspThings*;
       toSortMO.parent.setChildIndex(toSortMO, i);
    }
  }

```

The problem after it is called it appears the x position becomes 0  
and the scaleX becomes close to 1 or 0 just making a thin streak on the screen  
Trace however reveals this isnt the case.  
Anyone ideas thanks.
