Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
No problem! 2011/1/13 natalia Vikhtinskaya > THANK YOU AGAIN!!! > > 2011/1/13 Juan Pablo Califano : > > PS: > > > > I mentioned that a random sort was not the best approach. > > > > Here's a better way to randomize an array: > > > > public static function shuffle(array:Array):void { > >var

Re: [Flashcoders] Unique array AS3

2011-01-13 Thread natalia Vikhtinskaya
THANK YOU AGAIN!!! 2011/1/13 Juan Pablo Califano : > PS: > > I mentioned that a random sort was not the best approach. > > Here's a better way to randomize an array: > > public static function shuffle(array:Array):void { >    var tmp:*; >    var cur:int; >    var top:int; > >    cur = top = array.

Re: [Flashcoders] Unique array AS3

2011-01-13 Thread natalia Vikhtinskaya
Thank you very much!! Now it works well. 2011/1/13 Juan Pablo Califano : > Try this: > > function uniqueRandomInt(min:Number, max:Number, n:Number) { >  var a:Array = []; >  var i:Number = min; >  while (a.push(i++)  a.sort(function (a:Number, b:Number) { >  return Math.floor(Math.random()*3)-1; >

Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
PS: I mentioned that a random sort was not the best approach. Here's a better way to randomize an array: public static function shuffle(array:Array):void { var tmp:*; var cur:int; var top:int; cur = top = array.length; if(top) { while(--top) { cur = Math.

Re: [Flashcoders] Unique array AS3

2011-01-13 Thread Juan Pablo Califano
Try this: function uniqueRandomInt(min:Number, max:Number, n:Number) { var a:Array = []; var i:Number = min; while (a.push(i++) 0) as evenly distributed as possible. Math.random gives you a number that is great or equal to 0 and *less* than 1. It will not give you 1 back (0.9, but not 1

[Flashcoders] Unique array AS3

2011-01-13 Thread natalia Vikhtinskaya
Hi I use function that creates unique array function uniqueRandomInt(min:Number, max:Number, n:Number) { var a:Array = []; var i:Number = min; while (a.push(i++)http://chattyfig.figleaf.com/mailman/listinfo/flashcoders