Limit to length of LineTo?

The following is on an enterframe event:

Code:
function drawLine(event:Event):void {
rootNode.x -= 5;
myLine.graphics.lineTo(lnX +=5,lnY-=adjY);

}
…where myLine is contained in rootNode… the line is drawn to the right and rootnode is moved left… In essence… it looks like a stock ticker or heart rate monitor.

An example image:

And a swf example: meter.zip

My question is… how do I clean up the drawing after it scrolls off screen to left or can I just keep drawing the line forever and ever. Would I have to use clear and store points in an array? Any other ways to do this?

I’m assuming the app will eventually die because the line gets too big? It could be running for several hours or longer. It does get choppy after about 20 minutes.

Any help would be appreciated

maybe create points where line should begin/pass/end and redraw all when new point is added and old deleted

Once the line reaches the right edge of the page, draw() the line to a bitmapData object, and begin to move the bitmap and the line’s origin to the left while drawing. Once the line’s origin has moved to the left edge, repeat the process. Something like this:

var started:Boolean = false;
function drawLine(event:Event):void {
    if(myBitmap.x <= -stage.stageWidth){
        rootNode.x -= 5;
        myBitmap.x -= 5;
        myLine.x -= (started) ? 5 : 0;
        lnX += 5;
        var newX:Number = lnX % stage.stageWidth;
        myLine.graphics.lineTo(newX, lnY-=adjY);
    }else{
        started = true;
        myBitmapData.draw(rootNode);
        myBitmap.x = 0;
        myLine.x = stage.stageWidth;
        myLine.graphics.clear();
        myLine.graphics.lineStyle(1);
        lnX += 5;
        var newX:Number = lnX % stage.stageWidth;
        myLine.graphics.lineTo(newX, lnY-=adjY);
    }
}