Converting some AS2 while loop to AS3

Hi

I have a while loop I use that shuffles my array in AS2, I have to convert all my code to AS3 which seems to have an issue with the following:

var randomArray = shuffle(orderArray);
function shuffle(toShuffle) { // shuffles an array
	var newMcOrder = new Array();
	while (!end) {
		myRandom = random(toShuffle.length);
		selected = toShuffle[myRandom];
		toShuffle.splice(myRandom, 1);
		newMcOrder.push(selected);
		if (toShuffle.length == 0) end = true;
	}
	return newMcOrder;
}

Any idea what I need to do to get this working with AS3?

thanks

Ben