# Dynamic line drawing...setInterval

**URL:** https://forum.kirupa.com/t/dynamic-line-drawing-setinterval/158428
**Category:** Uncategorized
**Created:** [August 9, 2005, 5:47pm UTC](https://forum.kirupa.com/t/dynamic-line-drawing-setinterval/158428 "2005-08-09T17:47:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dtimothy](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@dtimothy](https://forum.kirupa.com/u/dtimothy)
#### Post date: [August 9, 2005, 5:47pm UTC](https://forum.kirupa.com/t/dynamic-line-drawing-setinterval/158428/1 "2005-08-09T17:47:28Z")

</div>

hi all…

i´m attempting to draw a line dynamically that takes points from a database array, which will draw over a certain time period rather than just appear too quickly that the eye doesn´t see it drawn. i´ve tried several permutations with the setInterval function but I´ve had no luck.

here´s the code i have that draws the line from the coordinates in the array…does anyone have any suggestions how i could make this happen?

thanks.

progressline ();

//based on totalmiles ™, finds the last element in the database array vtour to where the drawn line will stop  
function progressline () {  
if (tm \>= vtour\*[0] & tm \< vtour [i+1][0]) {  
determineline ();  
} else {  
i++;  
progressline ();  
}  
}

function determineline () {  
this.\_visible = false;  
this.lineStyle (2, 0xFF6633);  
this.moveTo (vtour[j][2], vtour[j][3]);  
//draws line to coordinates in database, stopping at last entry  
for (j=0; j \<= i; j++) {  
this.lineTo (vtour[j][2], vtour[j][3]);  
}  
//using geometry to dynamically find the coordinates to draw partial line if necessary  
if (tm \> vtour[j-1][0]) {  
//set the percent if tm is located between points in database  
var f:Number = (tm - vtour[j-1][0])/vtour[j-1][1];  
//draw that line  
this.lineTo ((f \* (vtour[j][2]-vtour[j-1][2]) + vtour [j-1][2]), (f \* (vtour[j][3]-vtour[j-1][3]) + vtour[j-1][3]));  
return;  
} else {  
return;  
}  
}
