# Creating a shape from a randomly drawn line

**URL:** <https://forum.kirupa.com/t/creating-a-shape-from-a-randomly-drawn-line/310661>\
**Category:** flash\
**Created:** [June 16, 2010, 2:14am UTC](https://forum.kirupa.com/t/creating-a-shape-from-a-randomly-drawn-line/310661 "2010-06-16T02:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flutillie](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@Flutillie](https://forum.kirupa.com/u/Flutillie)\
**Post date:** [June 16, 2010, 2:14am UTC](https://forum.kirupa.com/t/creating-a-shape-from-a-randomly-drawn-line/310661/1 "2010-06-16T02:14:21Z")

</div>

I have a line randomly being drawn and moved across the stage. Here is the code:

```php
import flash.display.Sprite;

var xValue:Number = 0;  
var yValue:Number = 150;   

//sprite in which the line will be created
var edgeHolder:Sprite = new Sprite();
addChild(edgeHolder);

//define lineStyle and starting positon
edgeHolder.graphics.lineStyle(3,0x00bb00);
edgeHolder.graphics.moveTo(xValue,yValue);  

edgeHolder.addEventListener(Event.ENTER_FRAME, drawRandom);  

function drawRandom(event:Event):void {  
    //reassign the x and y positions
	xValue+=10;  
	yValue = 100 + (Math.random()*150);  
	
    // draw the line to the next point  
    edgeHolder.graphics.lineTo(xValue,yValue); 
	
	 
	
	//move edgeHolder to the left once the line is across the entire stage
	if(xValue>=stage.stageWidth) {
		edgeHolder.x-=10;
	}
}   

```

Is there any simple way to create a filled in shape that covers the entire area of the stage above the line being created? Or any other way of filling in this space?

Thanks.
