Game using random frame feature

Hi,

I’m building a game where on the press of a button a movie clip jumps to a random frame to display a question.

I know how to choose a random frame, but I need to be able to choose a random frame between two specific points, say from between frame 8 and 32.

Secondly, once a particular question has been chosen once, I don’t want it to be available to be chosen again until all of the other questions have been viewed - to stop repeated questions.

Any idea how I can do this – my actionscript is still a little basic :blush:

Thanks…

Answered my own question:

In the actions layer create an array and shuffle it:

Array.prototype.shuffle = function() {
var shuffledArray = [];
var copyArray = this.slice(0);
for (var j = 0; j<this.length; j++) {
randomNo = Math.floor(Math.random()*copyArray.length);
shuffledArray[j] = copyArray[randomNo];
copyArray.splice(randomNo, 1);
}
return shuffledArray;
};
QuestionNumbers = [1,2,3,4,5,6,7,8,9,10];
RandomQuestion = QuestionNumbers.shuffle();
trace("RandomQuestion = "+RandomQuestion);

Then on the button to chose a question:

on (release) {
if (RandomQuestion.length == 0) {
RandomQuestion = QuestionNumbers.shuffle();
trace(“RandomQuestion=”+RandomQuestion);
capture = RandomQuestion.shift();
trace(capture);
} else {
capture = RandomQuestion.shift();
trace(capture);
}
}

This displays the first entry in the array and deletes it. If the array is empty, a new array is created. Random questions forever!

Hope this helps someone else…