Random questions

I have made a Who Wants to be a Millionare game but the questions aren’t random. I have made that every question is in it’s own scene. Which action to put on the button that will take you to a random scene? But then again, there is a problem. There should be 15 questions so there should be a limit of 15. At 15th you would be taken to the end of the game (last scene). Huh…any suggestions or can it be made easier?

i think it would be easier if you place all the questions in the same scene …

you could try something like … :

in the first frame you’d have the button to begin the game. let’s say you have a total of 20 questions … but you just want to ask 15. so frame 1 would be the beginning of the game, frames 2 to 21 are the questions and frame 22 is the end of the game

frame 1


// number of questions asked
questionNum = 0
// total of questions
questions = 20
// stop movie
stop()

button actions

on (release) {
	if (_root.questionNum < 15) {
		// create a random number between 2 and 21
		num = Math.ceil((Math.random()*_root.questions) + 1)
		// gotoAndStop in that frame
		_root.gotoAndStop (num)
		// add 1 to the questions already asked
		_root.questionNum += 1
	} else {
		// end game if the questions asked is 15
		_root.gotoAndStop (22)
	}
}

anyway … you might find useful this thread if you still want to make each question in its own scene
http://www.kirupaforum.com/showthread.php?s=&threadid=13976&highlight=*array*