Return to Snippet

Revision: 55556
at February 11, 2012 03:51 by donnydonny


Initial Code
var baseArray:Array; 
var numToGet:int = 8; 

function makeBaseArray(f_length:int):void
{
	baseArray = new Array();
	for (var i:int = 0; i < f_length; i++)
	{
		baseArray.push(i);
	}
}

function getRandomNoRepeat():Number
{
	var index:int = Math.random() * baseArray.length;
	var value:int = baseArray.splice(index,1)[0];
	return value;
}

makeBaseArray(16);

for (var i:int = 0; i < numToGet; i++)
{
	trace(getRandomNoRepeat());
}

Initial URL

                                

Initial Description
Random generator with no repetiotion using ActionScript 3

Initial Title
ActionScript 3 - Shuffle (random no repetition)

Initial Tags

                                

Initial Language
ActionScript 3