8 random numbers of 167

how can i get 8 random (and DIFFERENT) numbers out of 167(random(167))?
6 must be also excluded (6 - a variable)

shuffle = function () {
return Math.round(Math.random());
};
myArray = ;
for (var i = 1; i<168; i++) {
myArray.push(i);
}
myArray.splice(5, 1);
myArray.sort(shuffle);
for (var j = 0; j<8; j++) {
trace(“myArray[”+j+"] = "+myArray[j]);
}

hm… before today i have never used arrays… but i should learn them quick, cause’ as i can see, they can do a lots of miracles :wink:

now, about that script…

can i do this? (if i want to exclude the _parent._parent._currentframe-1,1)
myArray.splice(_parent._parent._currentframe);

and if i want to get those randomly chosen numbers to different variables, then is this correct?
vale1 = j[0] (“vale1” must equal to the first randomly picked number)
vale2 = j[1] (etc.)
vale3 = j[2]
vale4 = j[3]
vale5 = j[4]
vale6 = j[5]
vale7 = j[6]
vale8 = j[7]

ok, i got it :slight_smile:
it should be like this? (if i want to exclude the _parent._parent._currentframe and vale1,vale2, etc, must have those values)

shuffle = function () {
return Math.round(Math.random());
};
myArray = [];
for (var i = 1; i<168; i++) {
myArray.push(i);
}
myArray.splice(_parent._parent._currentframe-1, 1);
myArray.sort(shuffle);
for (var j = 0; j<8; j++) {
trace(“myArray[”+j+"] = "+myArray[j]);
vale1 = myArray[j-7];
vale2 = myArray[j-6];
vale3 = myArray[j-5];
vale4 = MyArray[j-4]
vale5 = MyArray[j-3]
vale6 = MyArray[j-2]
vale7 = MyArray[j-1]
vale8 = MyArray[j]
}