# RandomSeed equivalent in Actionscript?

**URL:** <https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676>\
**Category:** flash\
**Created:** [March 20, 2006, 5:33pm UTC](https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676 "2006-03-20T17:33:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kutyadog](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kutyadog](https://forum.kirupa.com/u/kutyadog)\
**Post date:** [March 20, 2006, 5:33pm UTC](https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676/1 "2006-03-20T17:33:42Z")

</div>

Having worked in Director using Lingo, I am wondering if Flash has a RandomSeed equivalent in ActionScript?  
For those of you not familiar with RandomSeed, it is the number that allows the computer to come up with ‘random’ numbers. By setting this number you can then get predictable results everytime. It can be very useful.  
Thanks  
chris

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [March 20, 2006, 5:39pm UTC](https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676/2 "2006-03-20T17:39:42Z")

</div>

> [@kutyadog](#):
>
> Having worked in Director using Lingo, I am wondering if Flash has a RandomSeed equivalent in ActionScript?  
> For those of you not familiar with RandomSeed, it is the number that allows the computer to come up with ‘random’ numbers. By setting this number you can then get predictable results everytime. It can be very useful.  
> Thanks  
> chris

[AS]myNumber = Math.round(Math.random()\*6); // random integer from 0 to 6[/AS]

---

<div class="post-metadata">

**Author:** ![kutyadog](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kutyadog](https://forum.kirupa.com/u/kutyadog)\
**Post date:** [March 21, 2006, 10:07pm UTC](https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676/3 "2006-03-21T22:07:04Z")

</div>

> [@BlueNar](#):
>
> ```
> ActionScript Code:
> [FONT=Courier New][LEFT]myNumber = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]*[COLOR=#000080]6[/COLOR][COLOR=#000000])[/COLOR]; [COLOR=#808080]*// random integer from 0 to 6 *[/COLOR]
> 
> ```
> 
> [/LEFT]  
> [/FONT]

thanks, BlueNar, but I should have been much more descriptive in my request. You are demonstrating the Math.random() function, which i am well aware of. I am looking for a randomSeed() ‘like’ function.

I will give more detail.

In Lingo (for Director), you have a function called RandomSeed. Really I guess it is a variable that is the root number that the computer uses to get its random numbers.

If you set this variable to a specific number, the sequence of random numbers generated afterwards will always be the same. So for example we have the following code:

randomseed = 1234567;  
while (i\<10) {  
trace( [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR]COLOR=#000000 [/COLOR]);  
i += 1;  
}

Output might be: 5,2,4,1,6,6,2,5,4.

Run it again, and the output would be EXACTLY the same everytime. Unless of course you change or remove the randomseed.

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [March 21, 2006, 10:46pm UTC](https://forum.kirupa.com/t/randomseed-equivalent-in-actionscript/182676/4 "2006-03-21T22:46:49Z")

</div>

There is nothing like that in Flash at this time.
