[flashpro] Unique method for Array Objects

Timo Stamm t.stamm at macnews.de
Thu Mar 10 15:11:20 EST 2005


Hello all,


I wrote a method to return the unique elements of an array:

Array.prototype.unique = function () {
	o = [];
	for (i in this) {
		d = 0;
		for (j in o) {
			if (o[j] == this[i]) {
				d++;
			}
		}
		if (d < 1) o.push(this[i]);
	}
	return o.reverse();
}
ASSetPropFlags(Array.prototype, null, 1);


trace ([1, 2, 2].unique()); // gives "1,2"



Timo


More information about the FlashPro mailing list