# Just A Simple Random As

**URL:** <https://forum.kirupa.com/t/just-a-simple-random-as/62821>\
**Category:** flash\
**Created:** [August 31, 2004, 6:19pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821 "2004-08-31T18:19:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dominerd](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@Dominerd](https://forum.kirupa.com/u/Dominerd)\
**Post date:** [August 31, 2004, 6:19pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/1 "2004-08-31T18:19:56Z")

</div>

I need to find an action script that tells a random movie clip scene to play… You see I have a movie clip with two frames ( each with “stop” in the AS), but when I export the film, I want it to randomly pick which of the two frame to show…

Could anyone help me out?

---

<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 31, 2004, 6:37pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/2 "2004-08-31T18:37:27Z")

</div>

search Random, Random Number, and/or Random Frame in the forums. I think this has been answered before.

:hr:

---

<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 31, 2004, 7:00pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/3 "2004-08-31T19:00:16Z")

</div>

> [@lunatic](#):
>
> search Random, Random Number, and/or Random Frame in the forums. I think this has been answered before.
> 
> :hr:

I tried it and nothing I was looking for poped up.

---

<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 31, 2004, 7:12pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/4 "2004-08-31T19:12:00Z")

</div>

set a variable to a random number. Do some research on how to make a random integer because the random function in flash generates a random number between 0 and 1 so you have to do some multiplying (to get the number to be between 1 and 2) and some rounding (using either floor or ceiling to get it to be exactly 1 or exactly 2).

Then its just a matter of setting the gotoAndPlay(yourrandomvariable).

:hr:

---

<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 31, 2004, 7:14pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/5 "2004-08-31T19:14:46Z")

</div>

> [@Dominerd](#):
>
> I tried it and nothing I was looking for poped up.

v = Math.ceil(Math.random()\*2);  
mc.gotoAndStop(v);

---

<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 31, 2004, 7:17pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/6 "2004-08-31T19:17:02Z")

</div>

Actually I did some searching of my own and its even simpler that that!

Try this:

```auto

num=random(2)+1;
trace(num)

```

you’ll only get 1 or 2 every time.

:hr:

---

<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 31, 2004, 8:07pm UTC](https://forum.kirupa.com/t/just-a-simple-random-as/62821/7 "2004-08-31T20:07:49Z")

</div>

> [@lunatic](#):
>
> Actually I did some searching of my own and its even simpler that that!
> 
> Try this:
> 
> ```auto
> 
> num=random(2)+1;
> trace(num)
> 
> ```
> 
> you’ll only get 1 or 2 every time.
> 
> :hr:

Yeh i use random() too but it is deprecated and we should really be using Math.random()
