# Random frame names

**URL:** <https://forum.kirupa.com/t/random-frame-names/204922>\
**Category:** Uncategorized\
**Created:** [October 24, 2006, 4:48pm UTC](https://forum.kirupa.com/t/random-frame-names/204922 "2006-10-24T16:48:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zao](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zao/32/141_2.png) [@zao](https://forum.kirupa.com/u/zao)\
**Post date:** [October 24, 2006, 4:48pm UTC](https://forum.kirupa.com/t/random-frame-names/204922/1 "2006-10-24T16:48:48Z")

</div>

Anyone have any code handy that will randomly select a frame name and play that section?

Basically I want a section to play, then upon the last frame in that section a code will be executed to randomly select another frame name(section).

---

<div class="post-metadata">

**Author:** ![brianmanden](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@brianmanden](https://forum.kirupa.com/u/brianmanden)\
**Post date:** [October 24, 2006, 6:54pm UTC](https://forum.kirupa.com/t/random-frame-names/204922/2 "2006-10-24T18:54:41Z")

</div>

1. Make an array with your frame names
2. Randomly choose one from the array
3. gotoAndPlay(the chosen name);

There might be some trouble in going to the value of a variable so in that case look into the eval() function.

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [October 24, 2006, 10:07pm UTC](https://forum.kirupa.com/t/random-frame-names/204922/3 "2006-10-24T22:07:44Z")

</div>

Something like this should work:

```auto
var frames:Array = ['coolFrame', 'neatFrame', 'awesomeFrame', 'wowFrame', 'niceFrame'];
gotoAndPlay(frames[Math.floor(Math.random()*frames.length)]);

```

You shouldn’t need to worry about using _eval_. When moving the playhead to a labeled frame, _gotoAndPlay_ accepts a string as the only parameter, and the elements of the array are all strings.

---

<div class="post-metadata">

**Author:** ![zao](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zao/32/141_2.png) [@zao](https://forum.kirupa.com/u/zao)\
**Post date:** [October 24, 2006, 10:34pm UTC](https://forum.kirupa.com/t/random-frame-names/204922/4 "2006-10-24T22:34:07Z")

</div>

That’s perfect man, thanks.
