Ah, so obj.stats is an Object and not an Array? You shouldn't rely on iteration order for hashtable types in general, but especially since the ECMAScript specification says iteration order is up to the object and hence implementation specific. (Note that you can define an iteration order for dynamic types if you subclass flash.utils.Proxy). I would write a custom type that maintains an internal Array to preserve key order and an Object that is the map of keys to values.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bjorn - Sent: Tuesday, April 17, 2007 3:18 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Looping through sorted ObjectProxy Actually, it doesn't .. If I look in my debugger - this is how the object looks: obj.stats = Object (@3ff4c81) [13] = Object (@3ff40c1) [14] = Object (@40333c1) [15] = Object (@3ec07a1) [16] = Object (@a973301) The code: for( var i:String in obj.stats) { trace(i); } for each (var value:Object in obj.stats) { trace(value.week); } will output: 16 13 14 15 16 13 14 15 .. it always starts with the last, before moving to the first .. Best regards, Bjørn On 16 Apr 2007 17:02:20 -0700, Bjorn Schultheiss <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: Hey Bjørn, "for in" loops in reverse. "for each" should give you what you need. regards, Bjorn On 17/04/2007, at 5:11 AM, bjorn - wrote: 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.juicabil <http://www.juicability.com/> ity.com <http://ity.com/> - flex blog http://www.43min. <http://www.43min.com/> com - funny movies -- ======================== http://www.juicability.com <http://www.juicability.com> - flex blog http://www.43min.com <http://www.43min.com> - funny movies