# Draw a moving line from (400,100) to (500, 150)

**URL:** https://forum.kirupa.com/t/draw-a-moving-line-from-400-100-to-500-150/269236
**Category:** flash
**Created:** [August 25, 2008, 6:31am UTC](https://forum.kirupa.com/t/draw-a-moving-line-from-400-100-to-500-150/269236 "2008-08-25T06:31:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![florencec2046](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@florencec2046](https://forum.kirupa.com/u/florencec2046)
#### Post date: [August 25, 2008, 6:31am UTC](https://forum.kirupa.com/t/draw-a-moving-line-from-400-100-to-500-150/269236/1 "2008-08-25T06:31:08Z")

</div>

Hi hi,

I am newbie in AS3. This forum is great. With the replies of my previous post, I have learned how to draw vertical, horizontal or with 45 degrees moving line.

But what if I want to draw a line from (400,100) to (500, 150)… I think I need to use some sine, cos or tan formula to increment … right ?? :

* * *

var line:Sprite = new Sprite;  
addChild(line);

with (line.graphics) {  
clear();  
moveTo(400, 100);  
lineStyle(1, 0xff6600);  
lineTo(500, 150);  
}

var sp:Sprite = new Sprite;  
addChild(sp);  
var lineY:uint = 100;  
var lineX:uint = 400;

function drawLine(e:Event):void {

```
with (sp.graphics) {
	clear();
	moveTo(400, 100);
	lineStyle(1, 0xff6600);
	lineTo(lineX++, lineY++); // I know this is not correct !!!!
}
trace("lineX = ", lineX, " lineY = ", lineY);

if ((lineY&gt;150) || (lineX&gt;500)) {
	removeEventListener(Event.ENTER_FRAME,drawLine);
}

```

}

addEventListener(Event.ENTER\_FRAME,drawLine);

* * *

Please show me how to achieve this.

Thanks

Florence
