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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 15, 2003, 11:40pm UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/2 "2003-12-15T23:40:16Z")

</div>

trace this:

[AS]trace (\_root[“horse”+n].)\_x);[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 15, 2003, 11:55pm UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/3 "2003-12-15T23:55:00Z")

</div>

thanks norie, but it’s still not happy.

It gives the following output when I run the movie - I put your trace in Line 13.

Scene=Scene 1, Layer=script, Frame=4: Line 13: Expected a field name after ‘.’ operator.  
trace (\_root[“horse”+n].)\_x);

Scene=Scene 1, Layer=script, Frame=4: Line 17: Unexpected ‘}’ encountered  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2003, 12:02am UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/4 "2003-12-16T00:02:36Z")

</div>

opps sorry,

```auto

trace (_root["horse"+n]._x);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2003, 12:08am UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/5 "2003-12-16T00:08:25Z")

</div>

Thanks norie!

it is working great (now to solve my sorting problem!)

much appreciated,

Roughy

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2003, 12:19am UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/6 "2003-12-16T00:19:09Z")

</div>

```auto
myArray.sort(Array.NUMERIC);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2003, 1:25am UTC](https://forum.kirupa.com/t/fmx-sorting-x-values-of-movie-clips/96963/7 "2003-12-16T01:25:07Z")

</div>

thanks again norie - will work on it
