# \[FMX\] Sorting X values of movie clips

**URL:** <https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/37915>\
**Category:** flash\
**Created:** [December 15, 2003, 10:41pm UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/37915 "2003-12-15T22:41:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roughy](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@Roughy](https://forum.kirupa.com/u/Roughy)\
**Post date:** [December 15, 2003, 10:41pm UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/37915/1 "2003-12-15T22:41:49Z")

</div>

Hi All,

I’ve got five movie clips (called horse1 through horse5) and I want to sort them to find out which has the highest x value. I thought putting them into an array and sorting that would be the best idea but I can’t seem to get even the array to work.

This is the code I have so far;

for (n=1; n\<6; n++) {  
var hr = “horse”+[n];  
myArray=[[“horse”+[n], \_level0.hr.\_x]];  
trace (\_level0.horse1.\_x);  
trace (myArray);  
}

which returns;

487.85  
horse1,  
487.85  
horse2,  
487.85  
horse3,  
487.85  
horse4,  
487.85  
horse5,

I used the ‘hr’ variable because myArray reported an error if I tried  
myArray=[[“horse”+[n], \_level0.“horse”[n].\_x]];

As you can see I do get an x value when I use  
trace (\_level0.horse1.\_x);

But I don’t get one if I use  
trace (\_level0.horse+[n].\_x);

Hope this makes some sort of sense. I’m pretty new to this so any help is appreciated.

I’m running Flash MX on a PC.

Thanks,

Roughy
