# Gotoandplay random frame

**URL:** <https://forum.kirupa.com/t/gotoandplay-random-frame/29306>\
**Category:** Uncategorized\
**Created:** [August 25, 2003, 3:59pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306 "2003-08-25T15:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DMX](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DMX](https://forum.kirupa.com/u/DMX)\
**Post date:** [August 25, 2003, 3:59pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306/1 "2003-08-25T15:59:41Z")

</div>

How can i make a button, on being clicked gotoand stop at any frame 1 - 7 inclusive. plz help.

---

<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:** [August 25, 2003, 4:03pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306/2 "2003-08-25T16:03:42Z")

</div>

[AS]gotoAndStop(Math.floor(Math.random()\*7+1));[/AS]  
[http://www.macromedia.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary456.html](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary456.html)  
[http://www.macromedia.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary466.html](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary466.html)

---

<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:** [August 25, 2003, 4:06pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306/3 "2003-08-25T16:06:53Z")

</div>

You would use the random() function.

Method 1: [AS]gotoAndStop(random(7)+1)[/AS]

Method 2: [AS]gotoAndStop(Math.floor(Math.random()\*7+1))[/AS]

random() is deprecated syntax and was replaced by Math.random(), but it works faster and is easier to type, so it is still used (for now at least). Math.random() is the new method and if you don’t understand how it works you can read up on it here…

[http://www.kirupa.com/developer/actionscript/tricks/random.htm](http://www.kirupa.com/developer/actionscript/tricks/random.htm)

edit: kode beat me :evil:

---

<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:** [August 25, 2003, 4:12pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306/4 "2003-08-25T16:12:37Z")

</div>

thnx.:+)

---

<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:** [August 25, 2003, 4:13pm UTC](https://forum.kirupa.com/t/gotoandplay-random-frame/29306/5 "2003-08-25T16:13:24Z")

</div>

Welcome. :beam:
