Thanks for answering Alex. I solved it by adding a sort_order on the server
side and using it for index when creating an Array on the client.

like this:

for each (var value:Object in obj.stats) {
 arr[ value.sort_order ] = value;
}

.. I was just puzzled by the fact that it always looked correctly sorted in
the debugger, and that it was outputted in a consistent but wrong order
using for .. in :)

Best regards,
Bjørn



On 17 Apr 2007 06:01:27 -0700, Alex Harui <[EMAIL PROTECTED]> wrote:

   For..in does not guarantee order.  You could theoretically call it
twice and get different results.

You might have to find a way to get an array.

 ------------------------------
*From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
Behalf Of *bjorn -
*Sent:* Monday, April 16, 2007 12:06 PM
*To:* flexcoders@yahoogroups.com
*Subject:* [flexcoders] Looping through sorted ObjectProxy



 I'm getting a sorted ObjectProxy from a server. In my debugger it looks
like this:

obj.stats = Object (@b90e661)
 [51] = Object (@b90e541)
 [52] = Object (@b90e361)
 [1] = Object (@b90e121)
 [2] = Object (@b90e9e1)

(its week numbers linked to Objects, btw).

However, when I use for() like this:

for( var i:String in obj.stats) {
      trace(obj.stats[i])
}

.. i get them in a different order (it starts with 2, then goes back to
51).

Why does for() behave this way? .. and how can I loop through them in the
order I see in my debugger?

Best regards,
Bjørn
--

========================
http://www.juicability.com - flex blog
http://www.43min.com - funny movies




--

========================
http://www.juicability.com - flex blog
http://www.43min.com - funny movies

Reply via email to