# Math.random Error 1137 Issue

**URL:** <https://forum.kirupa.com/t/math-random-error-1137-issue/319180>\
**Category:** flash\
**Created:** [February 11, 2011, 3:42am UTC](https://forum.kirupa.com/t/math-random-error-1137-issue/319180 "2011-02-11T03:42:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phenom](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@Phenom](https://forum.kirupa.com/u/Phenom)\
**Post date:** [February 11, 2011, 3:42am UTC](https://forum.kirupa.com/t/math-random-error-1137-issue/319180/1 "2011-02-11T03:42:16Z")

</div>

Hi, I’m relatively new to Flash CS5 ActionScript 3.0 and I’m just trying to generate 3 lines on a canvas using Math.random to position them in 3 places along the y axis. yAnchor1-3 are variable integers and hLine1-3 are instantiated symbols from my library. If someone could provide me with the correct code on the yAnchor1 = etc line I’d greatly appreciate it. Here is the section of code so far.

function onPaint(event:MouseEvent)  
{  
pButton.removeEventListener(MouseEvent.CLICK, onPaint)  
pButton.alpha = .3;  
pButton.buttonMode = false;

```
        cButton.addEventListener(MouseEvent.CLICK, onClear)
        cButton.alpha = 1;
        cButton.buttonMode = true;
        
        yAnchor1 = Math.random(canvas.x, canvas.x + canvas.width);
        yAnchor2 = Math.random(canvas.x, canvas.x + canvas.width);
        yAnchor3 = Math.random(canvas.x, canvas.x + canvas.width);
        
        hLine1.x = canvas.x;
        hLine1.y = yAnchor1;
        addChild(hLine1);
        
        hLine2.x = canvas.x;
        hLine2.y = yAnchor2;
        addChild(hLine2);
        
        hLine3.x = canvas.x;
        hLine3.y = yAnchor3;
        addChild(hLine3);
    }
```
