Flash actionscript 3.0: Generating random Numbers with out repetation of the previous number in AS 3.0

Generating random Numbers with out repetation of the previous number in AS 3.0

Posted by Sankar.G | Posted in | Posted on 9:55 AM

var i:Number;
var a:Array=new Array("");
var b:Array=new Array("");
var c:Array=new Array("");


main();
function main()
{
for (i=1; i<
11; i++) {
a[i]=i;
}
for (i=1; i<
11; i++) {
var r:Number=a.length-1;
b[i]=Math.floor(Math.random()*r+1);
c[i]=a.splice(b[i],1);
}
for(i=1;i<
11;i++)
{
trace("n:"+c[i]);
}
}

Comments (0)