# Random Numbers

**URL:** <https://forum.kirupa.com/t/random-numbers/34277>\
**Category:** Uncategorized\
**Created:** [October 30, 2003, 5:29pm UTC](https://forum.kirupa.com/t/random-numbers/34277 "2003-10-30T17:29:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samster](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@Samster](https://forum.kirupa.com/u/Samster)\
**Post date:** [October 30, 2003, 5:29pm UTC](https://forum.kirupa.com/t/random-numbers/34277/1 "2003-10-30T17:29:33Z")

</div>

How Do I Play A Movie Clip Randomly. What is the code for it  
Its For [www.geocities.com/thesamsters/Dudes.swf](http://www.geocities.com/thesamsters/Dudes.swf)  
One of the tutorials Is to Create random Numbers  
But you dont acctually see the random numbers How Would i Put a Input box Or something FOr THe Random Numbers To Appear In.

And Can You Help Me

Plz help me 🙂 🙂

As i dont know much action script

Samster. 🙂

---

<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:** [October 30, 2003, 6:04pm UTC](https://forum.kirupa.com/t/random-numbers/34277/2 "2003-10-30T18:04:17Z")

</div>

for a text box, it has to be dynamic for you to change the text in it on the fly. Give the dynamic text box a variable name. (bottom right of properties panel) AND in your script, set that variable nam to equal what you want it to say. Ex:

info = “Your mom”;  
myTextBox = info;

The dynamic text box will then display the variable info, which obviously says “your mom”.

- no offense, that’s just my default text saying.

as far as the random movieclip question, i think you have to make an array with those mc’s in it. Then write a code that randomly selects one. Ex:

myArray = new Array()  
myArray[0] = blueMC  
myArray[1] = whiteMC  
myArray[2] = greenMC ////// and so on.

I can’t think of the random code right now, but i’m sure someone else will give it a try. Good Luck

---

<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:** [October 30, 2003, 6:05pm UTC](https://forum.kirupa.com/t/random-numbers/34277/3 "2003-10-30T18:05:15Z")

</div>

THX AALOT !!!  
So Will It look Like THis ??  
on (release) {

Math.floor(Math.random() \* (high - low))

- low;

Math.floor(Math.random() \* (67 - 10))

- 10;

info = “Random Number”;  
myTextBox = info;

}

---

<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:** [October 30, 2003, 7:15pm UTC](https://forum.kirupa.com/t/random-numbers/34277/4 "2003-10-30T19:15:37Z")

</div>

That Doesnt Seem To Work In THe Dynamic Text Box  
It COmes Up With .level Math.Random  
☹  
does anyone know y?

---

<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:** [October 30, 2003, 8:07pm UTC](https://forum.kirupa.com/t/random-numbers/34277/5 "2003-10-30T20:07:56Z")

</div>

How about this:

[AS]  
x = Math.floor(Math.random() \* 10);  
myTextBox.text = 'Random number = ’ + x;  
[/AS]

---

<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:** [October 30, 2003, 8:11pm UTC](https://forum.kirupa.com/t/random-numbers/34277/6 "2003-10-30T20:11:56Z")

</div>

shouuld i just write that for the action ofthe button ?

I dont think it works /

[AS]on(press)  
{

x = Math.floor(Math.random() \* 10);  
myTextBox.text = 'Randomnumber = ’ + x;

} [/AS]

---

<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:** [October 30, 2003, 8:21pm UTC](https://forum.kirupa.com/t/random-numbers/34277/7 "2003-10-30T20:21:57Z")

</div>

My code wil put the text "Random number = " and a random number from 0 to 9 in a dynamic text box with the instance name myTextBox.

That’s not what you asked in your first post, but I thought that was what you were trying to accomplish in your second post.

And my code works. I’ve tested it.

---

<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:** [October 30, 2003, 8:24pm UTC](https://forum.kirupa.com/t/random-numbers/34277/8 "2003-10-30T20:24:07Z")

</div>

oh sorry i was doing something wrong  
Doh! thx for your 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:** [October 30, 2003, 8:24pm UTC](https://forum.kirupa.com/t/random-numbers/34277/9 "2003-10-30T20:24:45Z")

</div>

and your file is offline

---

<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:** [October 30, 2003, 8:26pm UTC](https://forum.kirupa.com/t/random-numbers/34277/10 "2003-10-30T20:26:55Z")

</div>

its ment to be [www.geocities.com/thesamsters/Dude.swf](http://www.geocities.com/thesamsters/Dude.swf) Btw  
lol  
Thx For YOur Helps
