XML Image Slider - loop

Hi,

I’ve created a image slideshow with xml-driven images that slide to the right automatically, or with next and previous buttons. I currently have it set up to rewind to the beginning of the image sequence with a scripted tween after the last image using setInterval. I now need to change this functionality so the sequence is a continuous loop (in other words, when you click the next button on the last image, the first image slides in as the next image, instead of it rewinding back to the first image). I have posted my code below. I would be extremely grateful if somebody would be kind enough to help me figure this out.

Thanks!

import mx.transitions.Tween;
import mx.transitions.easing.*;
//-------------------------------
// Load XML
var adBanner_xml:XML = new XML ();
adBanner_xml.ignoreWhite = true;
adBanner_xml.load ("adBanner.xml");
adBanner_xml.onLoad = function (success:Boolean) {
    if (success) {
        trace ("XML loaded successfully!");
        trace ("-------------------------------------------------------");
        var adBanner = adBanner_xml.firstChild;
        var adsLength = adBanner.childNodes.length;
        trace (adsLength);
        buildAd (adsLength);
    }
    else {
        trace ("XML not loaded!");
    }
};
//---------------------------------------
// Variables
var maskWidth:Number = _root.contain_mc.adBanner_mc.adMask_mc._width;
var curPos:Number = _root.contain_mc.adBanner_mc.adImages_mc._x;
var newPos:Number;
//the higher the slower
var lengthOfTime:Number = 1;
var adArray:Array = new Array ();
var adLocation:Number = 0;
var adsLength:Number;
// TIMER VAR
var adInterval:Number;
//in milliseconds
var duration:Number = 6000;
//-------------------------------------------
// insert ad images and copy into adImages_mc
function buildAd (numberOfAds:Number) {
    adsLength = numberOfAds;
    
    for (var i:Number = 0; i < numberOfAds; i++) {
        var adName:String = "ad" + i + "_mc";
        adArray.push (adName);
        var prevAd:MovieClip = adArray[i - 1];

        _root.contain_mc.adBanner_mc.adImages_mc.ad_mc._visible = false;
        _root.contain_mc.adBanner_mc.adImages_mc.ad_mc.duplicateMovieClip (adName, i);
        _root.contain_mc.adBanner_mc.adImages_mc[adName]._x = i * 780;
        //-----------------
        // Insert xml values
        _root.contain_mc.adBanner_mc.adImages_mc[adName].adTitle_txt.text = adBanner_xml.firstChild.childNodes*.childNodes[0].firstChild;
        _root.contain_mc.adBanner_mc.adImages_mc[adName].adDesc_txt.text = adBanner_xml.firstChild.childNodes*.childNodes[1].firstChild;
        _root.contain_mc.adBanner_mc.adImages_mc[adName].adPrice_txt.text = adBanner_xml.firstChild.childNodes*.childNodes[2].firstChild;
        _root.contain_mc.adBanner_mc.adImages_mc[adName].imgPH_mc.loadMovie (adBanner_xml.firstChild.childNodes*.attributes.imgPath, i);
        //------------------
        _root.contain_mc.adBanner_mc.adImages_mc[adName].adID = i;
        //
    }
    //
    startInterval ();
}
//-------------------------------------------------------
// Move ad
function adMovement (adLocation) {
    adLocation = adLocation;
    clearInterval (adInterval);
    newPos = -(maskWidth * adLocation);
    // (Movie clip to be tweened, property of movieclip to change, type of easing, begin position, end position, duration of tween, use seconds(true) or frames(false);
    var tween_handler:Object = new Tween (_root.contain_mc.adBanner_mc.adImages_mc, "_x", Strong.easeOut, curPos, newPos, lengthOfTime, true);
    curPos = newPos;
    startInterval ();
}
//---------------------------------------------
// Arrow hit functions
_root.contain_mc.adBanner_mc.navArrows_mc.arrowLeft_mc.hit_btn.onRelease = function () {
    if (adLocation != 0) {
        adLocation--;
        adMovement (adLocation);
    }
};
_root.contain_mc.adBanner_mc.navArrows_mc.arrowRight_mc.hit_btn.onRelease = function () {
    if (adLocation < (adsLength-1)) {
        adLocation++;
        adMovement (adLocation);
    }
};
//-----------------------------------------------
// TIMER 
function rotateTimer ():Void {
    if (adLocation >= (adsLength - 1)) {
        //adCount = 0;
        adMovement (0);
        adLocation = 0;
    }
    else {
        adLocation++;
        adMovement (adLocation);
    }
}
//-----
function startInterval ():Void {
    adInterval = setInterval (rotateTimer, duration);
}
//----------------------------------------------
// Order Now button
function orderNow (adID) {
    var path:String = adBanner_xml.firstChild.childNodes[adID].attributes.linkPath;
    getURL (path);
}