# Random frames with no repeat

**URL:** <https://forum.kirupa.com/t/random-frames-with-no-repeat/233804>\
**Category:** flash\
**Created:** [July 27, 2007, 1:45am UTC](https://forum.kirupa.com/t/random-frames-with-no-repeat/233804 "2007-07-27T01:45:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeiaGraf](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/leiagraf/32/3602_2.png) [@LeiaGraf](https://forum.kirupa.com/u/LeiaGraf)\
**Post date:** [July 27, 2007, 1:45am UTC](https://forum.kirupa.com/t/random-frames-with-no-repeat/233804/1 "2007-07-27T01:45:45Z")

</div>

Hey guys!

This time I’m trying to access random frames between 1 and 10. That bit’s easy, yay for help files.

function randRange(min:Number, max:Number):Number {  
var randomNum:Number = Math.floor(Math.random() \* (max - min + 1)) + min;  
return randomNum;  
}

btn.onPress = function() {  
n = randRange(1,10);  
gotoAndStop(n);  
}

Now the problem is that I want it to visit each frame only once. So, to check this, I’ve popped a simple Boolean at the top of each frame called f1, f2, etc, but only for frames 1-5 for checking purposes. Whether it’s frames 1-5 or 1-10 doesn’t really matter at this point.

My problem is that I need to check that n against the number in my f variables. It’s easy to make a string, but how do I check that against a boolean?

frameCheck = “f”+n;  
trace(frameCheck);

I keep feeling like I’ve almost got it, and then the whole concept eludes me. My immediate problem is the checking, but if anyone knows a better way to do the checking, I’d be grateful (that’s the only reason I popped it up there).

Thanks heaps!
