Evening, I'm using this here code to produce some lines. Now, the problem I'm having is that at a certain point (820), I want the movie to start scrolling to the left. I can get this to work, however I can't get the proper speed. As you can see, I've used some code to try to determine the speed, but it isn't working out properly. It is close, but then ends up falling off.

I don't know how to rectify this. If anyone has some insight, please let me know.

PHP Code:
function lines (rxydxdy)
{
    var 
rthis.createEmptyMovieClip (this.getNextHighestDepth (), this.getNextHighestDepth ());
    
m.moveTo (xy), m.lineStyle (0), m.onEnterFrame = function ()
    {
        if (--
r)
        {
            
//trace ("x:" + x + " y:" + y);
            
this.lineTo (+= (dx x) / r+= (dy y) / r);
            
m._x -= m_move;
        }
        else
        {
            (
sdx dx random (50), dy random (Stage.height));
            
trace ("dx:" dx " tx:" tx);
            
trace ("dx-tx/20 + ((dx - tx) / framerate)= " m_move);
            if (
dx >= 820)
            {
                
m_move = ((tx) / framerate);
                
// m_move = ((dx - tx) / framerate);
            
}
            
tx x;
            
// tx = dx;
            
if (dy bottom || dy top)
            {
                while (
dy bottom || dy top)
                {
                    
dy random (Stage.height);
                }
            }
        }
    };
}
////
var left this.frame_mc._x 1;
var 
right left this.frame_mc._width;
var 
top this.frame_mc._y 5;
var 
bottom top this.frame_mc._height 5;
////
var 50;
var 
random (Stage.height);
var 
0;
var 
framerate 10;
var 
tx 0;
var 
m_move 0;
////
if (bottom || top)
{
    while (
bottom || top)
    {
        
random (Stage.height);
    }
}
//
lines (framerateleftthis.frame_mc._height 2ih);