# \[AS2 - Flash CS5\] Need help with Random frames please =)

**URL:** https://forum.kirupa.com/t/as2-flash-cs5-need-help-with-random-frames-please/312830
**Category:** flash
**Created:** [August 13, 2010, 3:02pm UTC](https://forum.kirupa.com/t/as2-flash-cs5-need-help-with-random-frames-please/312830 "2010-08-13T15:02:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Usio](https://avatars.discourse-cdn.com/v4/letter/u/7ea924/32.png) [@Usio](https://forum.kirupa.com/u/Usio)
#### Post date: [August 13, 2010, 3:02pm UTC](https://forum.kirupa.com/t/as2-flash-cs5-need-help-with-random-frames-please/312830/1 "2010-08-13T15:02:47Z")

</div>

Good morning people! this is my first post here in the forum, i need help with a quiz game im doing, im actually a newbie i’ve been learning along with this but this random frame thing i can’t do it x.x so here is the thing:

I have a 14 frames flash

on frame 2 it’s the “CORRECT ANSWER” page with a NEXT button that will take me to a random frame between 5 and 14 with the following coding (took it from another site and modified it):

coding for the frame

```auto

// random frames
var myarr=[0,1,2,3,4,5,6,7,8,9];
index = Math.ceil(Math.random() * 10);
num = myarr.splice(index, 1)[0];
function findNewFrame() {

    if(myarr.length == 0)
    {
        gotoAndStop(1);
    }
    else
    {
      
        gotoAndStop(num + 5);
    }

}

```

coding for the button

```auto

on(release){
findNewFrame() 
}

```

so, it does splice the value from the Array and it does take me to a random frame but the moment i go to the other frame (ex: frame 7 that has a button with on(release){gotoAndStop(2);}) it loads again the Array with the number 7 in it, (Array resets) how can i prevent this?

I hope i’ve explained myself my english kind of sucks :hang: and thanks for your replies in advance!
