# lineTo error while trying to graph

**URL:** https://forum.kirupa.com/t/lineto-error-while-trying-to-graph/69662
**Category:** flash
**Created:** [November 6, 2004, 4:31pm UTC](https://forum.kirupa.com/t/lineto-error-while-trying-to-graph/69662 "2004-11-06T16:31:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Veryfine007](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@Veryfine007](https://forum.kirupa.com/u/Veryfine007)
#### Post date: [November 6, 2004, 4:31pm UTC](https://forum.kirupa.com/t/lineto-error-while-trying-to-graph/69662/1 "2004-11-06T16:31:24Z")

</div>

Bear with me, I new at this…I’m trying to create a stock graph. My method has been to use lineTo and moveTo to add graph segments to my movieclip stockGraph. stockGraph moves constantly along the X axis and does not vary on the Y axis. stockGraph is always positioned at 0. The new line segments are attached to stockGraph’s leftmost side (0 on the X axis) and go from 0 to -1 on the X axis – their Y points go up and down. When new line segments are added to stockGraph, stockGraphs X position becomes -1. stockGraph then moves itself back to 0 on the X axis.

Anyways, my code looks like this:  
Frame1:  
onClipEvent(enterFrame){  
nextpointY = currentstockprice  
with(\_root.stockGraph){  
moveTo(0, lastpointY)  
lineTo(-1, nextpointY)  
lastpointY = nextpointY  
}  
stockGraph.\_x += 1  
}  
Frame 2:  
\_root.gotoAndPlay(1)

In the beginning the stockGraph movieclip is positioned at x=0;  
The pen is positioned at x=0, y=the price quoted.

After the pen placement, a line is drawn from x=0 to x=-1 and y=the last price quote to y=the new price quote.

The pen draws a line to the newpoint from the old point (a distance -1 on the X axis) – This line becomes part of the stockGraph movieclip. With this new line attached, stockGraph is now positioned at x = -1;  
With its new line now part of it, stockGraph moves itself back to 0;

Frame 2 sends the file back to frame 1 to start over.

Going back to frame 1, the pen is again positioned at 0 and what is now the old price quote. The previous point and is ready to draw a line to the next point.

My problem is that lineTo isnt permanently adding to stockGraph and it ends up blinking in the same place over and over.
