Dissplay 6 numbers random but once only

[font=Arial]Im trying to display 6 numbers with actionscript, 1 to 6 but in random order and only used once.[/font]

[font=Arial]I tried Random function but that returns same numbers twice or more.[/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial]This is the code I used [/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial] Math.randomBetween = function(a,b) {[/font]

[font=Arial] return (a + Math.floor(Math.random()*(b-a+1)));[/font]

[font=Arial] }[/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial] for (var i = 4; i < 9; i++) {[/font]

[font=Arial] spread = Math.randomBetween(4, 8);[/font]

[font=Arial] [/font]

[font=Arial] [/font]

[font=Arial]Can anyone help[/font]

thanks

Have a look at this, its very similar to what you are trying to do http://www.gifsrus.com/testfile/randNumb.fla

You mean like this? (albeit a somewhat half-arsed way to do it, but whatever, i’m tired… hehe… and haven’t played with AS in a long time)

//prototype function to randomize the array
Array.prototype.randomize = function() {
	var arrayLength = this.length;
	var randNum, tempArray;
	for (i=0; i<arrayLength; i++) {
		randNum = Math.floor(Math.random()*arrayLength);
		tempArray = this*;
		this* = this[randNum];
		this[randNum] = tempArray;
	}
};
//array containing the digits you want displayed in random order
myArray = ["1", "2", "3", "4", "5", "6"];
//call this whenever you want to re-arrange the order of numbers
myArray.randomize();
//use myArray.join("") to display the array as a string of number values
trace(myArray.join(""));