# Random questions

**URL:** <https://forum.kirupa.com/t/random-questions/12679>\
**Category:** Uncategorized\
**Created:** [February 3, 2003, 12:58pm UTC](https://forum.kirupa.com/t/random-questions/12679 "2003-02-03T12:58:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luksy](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@luksy](https://forum.kirupa.com/u/luksy)\
**Post date:** [February 3, 2003, 12:58pm UTC](https://forum.kirupa.com/t/random-questions/12679/1 "2003-02-03T12:58:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 3, 2003, 2:10pm UTC](https://forum.kirupa.com/t/random-questions/12679/2 "2003-02-03T14:10:49Z")

</div>

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**

```auto

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

```

**button actions**

```auto
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\*](http://www.kirupaforum.com/showthread.php?s=&threadid=13976&highlight=%2Aarray%2A)
