Actionscript 3 while loop with indexOf
Posted
by Hanpan
on Stack Overflow
See other posts from Stack Overflow
or by Hanpan
Published on 2010-04-21T09:05:20Z
Indexed on
2010/04/21
12:13 UTC
Read the original article
Hit count: 250
actionscript-3
Hi,
Is there any reason why this loop is getting stuck? I can't quite get my head around it:
var i:Number = -1;
do
{
i = Math.round(Math.random() * _totalQuestions);
}
while(_usedQuestions.indexOf(i));
Where _usedQuestions is an array of numbers. This array starts empty.
Thanks!
Edit: I want the loop to end if i is NOT found in the array.. this way I know the question I have selected has not previously been asked.
© Stack Overflow or respective owner