# Drawing API

**URL:** https://forum.kirupa.com/t/drawing-api/28114
**Category:** Uncategorized
**Created:** [August 10, 2003, 9:07am UTC](https://forum.kirupa.com/t/drawing-api/28114 "2003-08-10T09:07:07Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Digigamer](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digigamer/32/276_2.png) [@Digigamer](https://forum.kirupa.com/u/Digigamer)
#### Post date: [August 10, 2003, 9:07am UTC](https://forum.kirupa.com/t/drawing-api/28114/1 "2003-08-10T09:07:07Z")

</div>

Im messing around with the drawing API and I was wondering how you would go about making it so that the lines are accually drawn on the screen while you watch instead of just being there when you play the movie. I know you can put it the code in different frames so that the lines will appear one by one but I want to accually have it draw it while I watch. Thanks, Digigamer

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 9:16am UTC](https://forum.kirupa.com/t/drawing-api/28114/2 "2003-08-10T09:16:24Z")

</div>

I’m pretty sure thats not possible…:-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 9:51am UTC](https://forum.kirupa.com/t/drawing-api/28114/3 "2003-08-10T09:51:56Z")

</div>

Put the different points where you want to draw in an array, and then draw onEnterFrame. Let’s say you want to draw a diagonal. The points will be (0,0), then (5, 5) for instance, (10,10) [size=1]I just imgined that the increment is 5, it can be anything you want, really.[/size]

Then we can build the array:

```auto
myArray = [] ;
N_POINTS = 50 ;	// # of points you want
N_INC = 5 ; // increment

for ( var i = 0; i < N_POINTS; i++ ) {
	myArray.push ( { x:i*N_INC, y:i*N_INC } ) ;
}

```

Then we use an onEnterFrame to get each element of the array and draw to that point:

```auto
this.lineStyle ( 0 ) ;
this.moveTo ( myArray[0].x, myArray[0].y ) ;
this.onEnterFrame = function () {
	if ( pos < myArray.length ) {
		pos++ ;
		this.lineTo ( myArray[pos].x, myArray[pos].y ) ;
	}
	else delete this.onEnterFrame ;
}

```

pom 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 9:52am UTC](https://forum.kirupa.com/t/drawing-api/28114/4 "2003-08-10T09:52:51Z")

</div>

Oh, and by the way, in this case, the array is not necessary because the path is very simple, but I used it in case you want to draw something more complex.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 10:33am UTC](https://forum.kirupa.com/t/drawing-api/28114/5 "2003-08-10T10:33:49Z")

</div>

and then theres also  
[http://proto.layer51.com/d.aspx?f=952](http://proto.layer51.com/d.aspx?f=952)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 10:42am UTC](https://forum.kirupa.com/t/drawing-api/28114/6 "2003-08-10T10:42:19Z")

</div>

Impressive!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 12:55pm UTC](https://forum.kirupa.com/t/drawing-api/28114/7 "2003-08-10T12:55:43Z")

</div>

oh i read wrong, i thought he meant draw the lines while he was doin the action script on the same screen :-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 10, 2003, 12:59pm UTC](https://forum.kirupa.com/t/drawing-api/28114/8 "2003-08-10T12:59:37Z")

</div>

thats more or less possible too. (to a degree)  
[http://www.kirupaforum.com/forums/showthread.php?s=&postid=193101#post193101](http://www.kirupaforum.com/forums/showthread.php?s=&postid=193101#post193101)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 11, 2003, 12:49am UTC](https://forum.kirupa.com/t/drawing-api/28114/9 "2003-08-11T00:49:40Z")

</div>

alright! thanks Ilyas Masa, thats what I was looking for. And secocular thats cool as well but its way outta my league right now 🙂
