Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Allandt Bik-Elliott (Receptacle)
i had to order it from the states - it was great On 22 May 2007, at 19:58, eric e. dolecki wrote: holy wow - super samurai ;) I didn't know many even saw that one... On 5/22/07, Allandt Bik-Elliott (Receptacle) <[EMAIL PROTECTED]> wrote: i could barely read that - it looks ammmaaazing :D

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread eric e. dolecki
holy wow - super samurai ;) I didn't know many even saw that one... On 5/22/07, Allandt Bik-Elliott (Receptacle) <[EMAIL PROTECTED]> wrote: i could barely read that - it looks ammmaaazing :D thanks eric - when's the next super samurai book coming out? :) On 22 May 2007, at 18:18, eric e. d

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Allandt Bik-Elliott (Receptacle)
i could barely read that - it looks ammmaaazing :D thanks eric - when's the next super samurai book coming out? :) On 22 May 2007, at 18:18, eric e. dolecki wrote: You could prevent duplicates from being placed into the array in the first place. Or http://proto.layer51.com/d.aspx?f=1196

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Allandt Bik-Elliott (Receptacle)
8o thankyou On 22 May 2007, at 18:56, Steven Sacks wrote: From my XArray mixin class (all 3 are needed). /** * Returns a new array by removing duplicate values in Array. */ Array.prototype.uniq = function() { var r = []; var l = this.length; for (var a = 0; a < l; a+

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Allandt Bik-Elliott (Receptacle)
ah yeh - nice thanks :) On 22 May 2007, at 19:06, Jesse Graupmann wrote: You have it, just decrease the i after any splice. function removeArrayDuplicates ( array:Array ) { var a:Array = [].concat ( array ); a.sort(); for ( var i = 0; i < a.length; i++ ) {

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Allandt Bik-Elliott (Receptacle)
yeh - i started trying to do that but just got myself into a moody bluddle - i'll prolly go back and try to rewrite it a bit cleaner when i'm happy i'll hit deadline here's what i ended up with - var myTempArray:Array = []; designerArray.sort()

RE: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Jesse Graupmann
You have it, just decrease the i after any splice. function removeArrayDuplicates ( array:Array ) { var a:Array = [].concat ( array ); a.sort(); for ( var i = 0; i < a.length; i++ ) { if ( a[ i ] == a[ i + 1 ] ) a.splice ( --i + 1, 1 ); }

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Steven Sacks
From my XArray mixin class (all 3 are needed). /** * Returns a new array by removing duplicate values in Array. */ Array.prototype.uniq = function() { var r = []; var l = this.length; for (var a = 0; a < l; a++) { if (!r.has(this[a])) r.push(this[a]);

RE: [Flashcoders] remove duplicate items in array

2007-05-22 Thread Munson, Scott
Your function is fine if you want to only remove the 1st occurance of a repeat. However, 3 in a row will be only reduced to 2. I'm guessing that's what's happening to you. In other words, [1,1,2,3,3,4] will properly reduce to [1,2,3,4] with your function. However, [1,1,1,2,3,3,4] will only redu

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread eric e. dolecki
You could prevent duplicates from being placed into the array in the first place. Or http://proto.layer51.com/d.aspx?f=1196 You could rewrite a prototype as a regular function that takes the array as an argument. - eric On 5/22/07, Allandt Bik-Elliott (Receptacle) <[EMAIL PROTECTED]> wrote: h

Re: [Flashcoders] remove duplicate items in array

2007-05-22 Thread R�kos Attila
Don't you think that you should take into consideration that the length of the array can change during the loop? Attila ABER> //loop through items, removing any sitting next to a duplicate ABER> for (var i:Number = 0; i < myArray.length; i++) { ABER> if (myArray[i] == myArray[i+1]) { ABER>