It sure seems like the documentation is off from what it actually does. Maybe in the mapper function, you can push each iteration out to a new array instead. :-/\
Good luck! - Michael M. -----Original Message----- From: Kenneth Kawamoto [mailto:kennethkawam...@gmail.com] Sent: Friday, August 19, 2011 9:14 AM To: Mendelsohn, Michael Cc: kennethkawam...@gmail.com; Flash Coders List Subject: Re: [Flashcoders] Vector.map() private function arrayMapper(item:uint, index:uint, array:Array):uint { return item + 30; } trace([1, 2, 3, 4, 5].map(arrayMapper)); // traces 31,32,33,34,35 Array.map() does what it says it does. private function vectorMapper(item:uint, index:uint, vector:Vector.<uint>):uint { return item + 30; } trace(new <uint>[1, 2, 3, 4, 5].map(vectorMapper)); // traces undefined Vector.map() does, well, f-all. I can use forEach() to get what I want but this doesn't look right. Thanks for testing MM! Kenneth Kawamoto http://www.materiaprima.co.uk/ On 19/08/2011 13:36, Mendelsohn, Michael wrote: > You're right Kenneth. > > var g:Vector.<uint> = Vector.<uint>([1,2,3,4,5]); > var hh:Vector.<uint> = g.slice(); > var h:Vector.<uint> = g.map(mapper); > var a = 5; > function mapper(item:uint,ind:uint,g:Vector.<uint>):Vector.<uint>{ > trace(g[ind]+30); > return g; > } > > In this case, hh returns the vector, and h still returns null. > > - MM > > -----Original Message----- > From: Kenneth Kawamoto [mailto:kennethkawam...@gmail.com] > Sent: Thursday, August 18, 2011 5:15 PM > To: Flash Coders List > Cc: Mendelsohn, Michael > Subject: Re: [Flashcoders] Vector.map() > > What do you get for h? > > Kenneth Kawamoto > http://www.materiaprima.co.uk/ > > On 18/08/2011 21:08, Mendelsohn, Michael wrote: >> Hi Kenneth... >> >> This is working for me: >> >> var g:Vector.<uint> = Vector.<uint>([1,2,3,4,5]); >> var h:Vector.<uint> = g.map(mapper); >> function mapper(item:uint,ind:uint,g:Vector.<uint>):void{ >> trace(g[ind]+30); >> } >> >> Hope that helps, >> - Michael M. >> >> >> >> -----Original Message----- >> From: flashcoders-boun...@chattyfig.figleaf.com >> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kenneth >> Kawamoto >> Sent: Thursday, August 18, 2011 9:27 AM >> To: Flash Coders List >> Subject: [Flashcoders] Vector.map() >> >> Dear coders, >> >> Vector.map() is supposed to return a new Vector but it appears to return >> nothing (undefined). Is this working for you? _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders