Archive for September, 2008

AS3: Removing duplicates from an array

Just for shiggles (yes, I said it.), removing duplicate items from an array in one line of ActionScript 3:

var arr:Array = ["a","b","b","c","b","d","c"];
var z:Array = arr.filter(function (a:*,b:int,c:Array):Boolean { return ((z ? z : z = new Array()).indexOf(a) >= 0 ? false : (z.push(a) >= 0)); }, this);
trace(z);

Posted by Ash on September 3rd, 2008

Filed under Actionscript | 1 Comment »