Or use an anonymous function with one of the array operation methods, like every (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#every( ))
In this case your anonymous function would be something that increments a value in its parent scope by the value of the current element it is processing. Daryl's point about input validation is really good Karthik Karthik Kailash | Product SocialVision, Online Television Becomes a Social Experience CELL . 408.768.7704 | WEB . www.socialvisioninc.com | FACEBOOK . <http://www.facebook.com/socialvision> facebook.com/socialvision | TWITTER . <http://twitter.com/socialvision> twitter.com/socialvision From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of daryl_ducharme Sent: Friday, December 18, 2009 6:48 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Actionscript sum function If a function doesn't exist, roll your own. Something like the following should work. function getSum( ... nums ):Number { var total:Number = 0; for each( var number:Number in nums ) { total += number; } return total; } You may want to validate your inputs to have better error handling. --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "AJC2357" <ajc2...@...> wrote: > > Is there really no way to sum a simple array w/o adding element by element? > > var myArray:Array = [1,2,3,4,5]; > > I've found min and max functions, but nothing to sum... > > Any tips appreciated! >