# Problem w/ Math.random() in AS3

**URL:** https://forum.kirupa.com/t/problem-w-math-random-in-as3/196216
**Category:** flash
**Created:** [August 6, 2006, 10:25pm UTC](https://forum.kirupa.com/t/problem-w-math-random-in-as3/196216 "2006-08-06T22:25:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![voidoid](https://avatars.discourse-cdn.com/v4/letter/v/919ad9/32.png) [@voidoid](https://forum.kirupa.com/u/voidoid)
#### Post date: [August 6, 2006, 10:25pm UTC](https://forum.kirupa.com/t/problem-w-math-random-in-as3/196216/1 "2006-08-06T22:25:39Z")

</div>

To anyone who’s been playing with AS3…Here is my code

```auto
package {
    import flash.display.Sprite;
    import flash.text.*;

    public class RandomTester extends Sprite
    {
        public function RandomTester()
        {
            var txt:TextField = new TextField();
            txt.autoSize = TextFieldAutoSize.LEFT;
            txt.wordWrap = true;
            var output:String = ""
            
            for(var i:int = 0; i < 50; i ++) {
                output += (Math.random() * 100).toString() + "||" + "
";
            }
            txt.text = output;
            addChild(txt);
        }
    }
}

```

The textfield is there just because I can’t seem to get trace to work. Anyway, I keep getting identical sets of random numbers. Running the same .swf again and again, I get a few different sets of the SAME numbers . Does this have something to do with the way the random function is seeded? The docs say that the random number is calculated in an “undisclosed manner”. I am stumped. thanks in advance!
