Daily Archives: 29/05/2011

AS3 Object shuffle or randomize

After I published my AS3 Vector shuffle or randomize post, Philip Bulley commented: “…I tried casting a Vector.int to Vector.*, but the vector becomes null within the shuffle method”. I never had to randomize a Vector.<int> but when I tried I discovered Philip was right, the result was null.

I solved this problem by changing my shuffleVector function into a more generic shuffleObject function. It solves all casting problems and you can use the shuffleObject function to randomize Objects, Array and Vectors. So if you want to randomize or shuffle an Object, Array or Vector, please use this function below instead of my previous shuffleVector function.
Continue reading