Re: [flexcoders] Re: iterating across an object

2007-10-28 Thread Doug McCune
BTW, check out Josh Tynjala's writeup of some of the new stuff that's going to be in ECMAScript: http://www.zeuslabs.us/2007/10/28/discover-ecmascript-4-the-future-of-actionscript/ Included is Map :) You can read the document outlining some of the new stuff in ECMAScript 4 here:

[flexcoders] Re: iterating across an object

2007-10-27 Thread simonjpalmer
Thanks for your replies, I think I can probably use either Object or Dictionary as I know my keys are always Strings. However this raises another question, namely what do these iterators iterate through, the keys or the objects? In old Java speak I have a MapString, Dog map; if I say for each

[flexcoders] Re: iterating across an object

2007-10-27 Thread ben.clinkinbeard
// iterate over strings/property names for(var prop:String in obj) { trace(prop + = + obj[prop]); } // iterate over properties for each(var member:Object in obj) { trace(member); } Should be more complete descriptions in the docs. any idea why there is no formal Map object in AS3 Nope.

[flexcoders] Re: iterating across an object

2007-10-26 Thread hergy80
You can try (this works well with XML items, should work here I would imagine). for each(var mapItem:Object in map) { ... } --- In flexcoders@yahoogroups.com, simonjpalmer [EMAIL PROTECTED] wrote: In the absence of a formal Map I am using an object as a key/value pair map as follows: var

[flexcoders] Re: iterating across an object

2007-10-26 Thread ben.clinkinbeard
for...in and for...each will both work on Object but what you're really looking for is Dictionary. Dictionary supports those loops as well. HTH, Ben --- In flexcoders@yahoogroups.com, simonjpalmer [EMAIL PROTECTED] wrote: In the absence of a formal Map I am using an object as a key/value

[flexcoders] Re: iterating across an object

2007-10-26 Thread simonjpalmer
thanks, sorry to be dim, but what exactly do I put as the iterator in these loops? for each (what in map) Can I use... var o:Object; for each (o in map)? Incidentally I don't think a Dictionary works in my particular instance because it uses the strict equality === operator which means that I

[flexcoders] Re: iterating across an object

2007-10-26 Thread ben.clinkinbeard
Hi Simon, Dictionary will work for you. Strings are passed by value, so it doesn't matter if you have the same key var or not. Run this code to see an example. var d:Dictionary = new Dictionary(); var s1:String = foo; var s2:String = foo; d[s1] = bar; trace(d[s2]); As for what to use as the

[flexcoders] Re: iterating across an object

2007-10-26 Thread reflexactions
Why a Dictionary? A Dictionary was designed for Object keys not realy String keys. A plain old fashioned Object will surely do just fine for him, ie exactly as he had it in the first place the only thing he was missing was how to loop over the keys, which would just be: for(key:String in

[flexcoders] Re: iterating across an object

2007-10-26 Thread ben.clinkinbeard
Why a Dictionary? Because he was asking about HashMaps. As for his question about HashMaps/HashTables, Object is really the nearest equivialent. I would disagree, considering Dictionary supports Object keys and Object does not. Ben --- In flexcoders@yahoogroups.com, reflexactions [EMAIL