Issue with sliding movement, looping along a horizontal

ok people… here is a script I’m working on. I have few if any problems with it (amazing as that is) but there are two things that are tweeky about it and I’d be interested in input.

Any input I can get as to how to smooth up the transition of movement would be appreciated.


/*
An Original script by David A Haisley
August 10, 2006
*/
//The loadVars object for loading the data
var image_lv:LoadVars = new LoadVars();
//when the loadvars object receives the data
aPic = new Array();
aPic_Large = new Array();
aPic_Small = new Array();
aPic_Order = new Array();
var vCenter = Stage.width/2;
_root.createEmptyMovieClip("oThumbSlider",_root.getNextHighestDepth());
_root.createEmptyMovieClip("oTextSlider",_root.getNextHighestDepth());
_root.oThumbSlider._y=10;
_root.oThumbSlider._x=0;
_root.vThumbLeftMax=0;
// on load PHP success
image_lv.onLoad = function(success){
    if(success){
        aPic = this.filelist.split(",");
        for (i=0;i<aPic.length;i++){
            if(aPic*.substring(aPic*.length - 8,aPic*.length - 9)=="L"){
                aPic_Large.push(aPic*);
            }else if(aPic*.substring(aPic*.length - 8,aPic*.length - 9)=="S"){
                aPic_Small.push(aPic*);
            }
        }
        for (i=0;i<aPic_Small.length;i++){
            aPic_Order.push("oThumb"+i);
        }
        var mclListener:Object = new Object();
        mclListener.onLoadInit = function(target_mc:MovieClip) {
            if(_root.vThumbCount==aPic_Small.length-1){
                _root.vThumbRightMax = _root.oThumbSlider._x+(_root.oThumbSlider["oThumb"+vThumbCount]._x+_root.oThumbSlider["oThumb"+vThumbCount]._width);
            }
        }
        var image_mcl:MovieClipLoader = new MovieClipLoader();
        image_mcl.addListener(mclListener);
        for(i=0;i<aPic_Small.length;i++){
            _root.oThumbSlider.createEmptyMovieClip("oThumb"+i,_root.oThumbSlider.getNextHighestDepth());
            _root.oTextSlider.createTextField("text"+i,_root.oThumbSlider.getNextHighestDepth(),5,20*i,20,10);
            _root.oThumbSlider["oThumb"+i]._y = 0;
            _root.oThumbSlider["oThumb"+i]._x = _root.oThumbSlider._x + (120 * i);
            _root.vThumbCount=i;
            image_mcl.loadClip(aPic_Small*,_root.oThumbSlider["oThumb"+i]);
        }
    }else{
        trace("an error has occurred.");
    }
}
//listen for mouse interaction
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
    for(mc in _root.oThumbSlider){
        var point:Object = {x:_xmouse, y:_ymouse};
        _root.oThumbSlider.globalToLocal(point);
        if(_root.oThumbSlider[mc].hitTest(point.x,point.y)&&_root.oThumbSlider[mc]._name.substring(0,2)=="oT"){
            _root.createEmptyMovieClip("oPic",_root.getNextHighestDepth());
            //movie clip loader listener
            //stage = 800 by 600
            var mclListener:Object = new Object();
            mclListener.onLoadInit = function(target_mc:MovieClip) {
                target_mc._yscale=100;
                target_mc._xscale=100;
                var w:Number = target_mc._width;
                var h:Number = target_mc._height;
                if(w>=h){
                    //scale to width
                    var vScale = 650/target_mc._width*100;
                    target_mc._yscale = vScale;
                    target_mc._xscale = vScale;
                    target_mc._x = 400-target_mc._width/2;
                    target_mc._y = 370-target_mc._height/2;
                }else{
                    //scale to height
                    var vScale = 450/target_mc._height*100;
                    target_mc._yscale = vScale;
                    target_mc._xscale = vScale;
                    target_mc._x = 400-target_mc._width/2;
                    target_mc._y = 370-target_mc._height/2;
                }
            }
            var image_mcl:MovieClipLoader = new MovieClipLoader();
            image_mcl.addListener(mclListener);
            image_mcl.loadClip(aPic_Large[_root.oThumbSlider[mc]._name.substring(6,_root.oThumbSlider[mc]._name.length)],oPic);
        }
    }
}

Note the following. This is a code desided to slide created thumbnails left to right across the top of the movie. The two problems I am having are with this code. The slide to the right, is jerky. It sets the x location in such a way that I do not get a smooth transition when a movieclip reaches the end of the length of the oThumbSlider.

When the movie clips are sliding to the left, the speed of the slide is consistant until such a time as one MC transfers to the end of the oThumbSlider. Then they start rocketing along at a great pace.


mouseListener.onMouseMove = function(){
    //if the mouse is above the 100 y mark
    if(_ymouse<=100){
        //create an on enter frame function for the oThumbSlider
        _root.oThumbSlider.onEnterFrame = function(){
            //if the mouse is more than 140 to the left of the center x
            if(_xmouse<_root.vCenter-140){
                vDistance=_xmouse - _root.vCenter;
                for(mc in _root.oThumbSlider){
                    _root.oThumbSlider[mc]._x += vDistance / 90;
                    if(_root.oThumbSlider[mc]._x<vThumbLeftMax){
                        _root.oThumbSlider[mc]._x=vThumbRightMax;
                        _root.aPic_Order.push(_root.aPic_Order.shift());
                        for(i=0;i<aPic_Order.length;i++){
                            _root.oThumbSlider[aPic_Order*]._x = vThumbLeftMax + (120 * i);
                        }
                    }
                }
            //if the mouse is more than 140 to the right of the center x
            }else if(_xmouse>_root.vCenter+140){
                vDistance=_xmouse - _root.vCenter;
                for(mc in _root.oThumbSlider){
                    _root.oThumbSlider[mc]._x += vDistance / 90;
                    if(_root.oThumbSlider[mc]._x>vThumbRightMax){
                        _root.oThumbSlider[mc]._x=vThumbLeftMax;
                        _root.aPic_Order.unshift(_root.aPic_Order.pop());
                        for(i=0;i<aPic_Order.length;i++){
                            _root.oThumbSlider[aPic_Order*]._x = vThumbLeftMax + (120 * i);
                        }
                    }
                }
            }
        }
    }else{
        delete _root.oThumbSlider.onEnterFrame;
    }
}
Mouse.addListener(mouseListener);

Note this will eventually work off of a php file but currently is set to work off a text file. The txt file is displayed below. The swf and the php file will eventually sit in a folder with a number of jpgs named as the txt file below shows.


//load php
image_lv.load("test.txt");

test.txt file
filelist=Bearmountain_2004_L_001.jpg,Bearmountain_2004_L_002.jpg,Bearmountain_2004_L_003.jpg,Bearmountain_2004_L_004.jpg,Bearmountain_2004_L_005.jpg,Bearmountain_2004_S_001.jpg,Bearmountain_2004_S_002.jpg,Bearmountain_2004_S_003.jpg,Bearmountain_2004_S_004.jpg,Bearmountain_2004_S_005.jpg,Block_Island_L_001.jpg,Block_Island_L_002.jpg,Block_Island_L_003.jpg,Block_Island_L_004.jpg,Block_Island_L_005.jpg,Block_Island_L_006.jpg,Block_Island_S_001.jpg,Block_Island_S_002.jpg,Block_Island_S_003.jpg,Block_Island_S_004.jpg,Block_Island_S_005.jpg,Block_Island_S_006.jpg