XML blues. Sequentially parsing array

:skull:Hello,
I’m trying to convert a test file from AS2 to AS3. All I’m looking to do with this is to get my buttons to sequentially go through the titles in my XML file. Click NEXT BUTTON it takes you forward…Click PREV button it takes you back etc. etc. If you are on the last ( or first ) item & a button is pressed it will proceed to the first item in the array & visa versa.
I have no idea what I am doing anymore but I will post my LSD spider web actionscript debauchery in the event that someone wants to help a brotha out.

var currentlyPlaying:Number = 0;
var totalNumber:Number = 0;
/////////////////
nextButton.addEventListener(MouseEvent.CLICK, nextButtonclick);
prevButton.addEventListener(MouseEvent.CLICK, prevButtonclick);
nextButton.buttonMode = true;
prevButton.buttonMode = true;
/////////////////

var arTitle:Array = new Array(); // zero clue how to access the title nodes in array

/////////////////

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
 
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("media.xml"));


function LoadXML(e:Event):void {

xmlData = new XML(e.target.data);
ParseMedia(xmlData);

}
 
function ParseMedia(mediaInput:XML):void {

var titleList:XMLList  = mediaInput.theMedia.title;
 
for (var i:int = 0; i < xmlData.length(); i++){
    var titleElement:XML = titleList[currentlyPlaying];
    myTitle.text=titleList[currentlyPlaying];
    }
}

function nextButtonclick(event:MouseEvent):void {
    trace("next button clicked");
    nextItem();
    }
function prevButtonclick(event:MouseEvent):void {
    trace("prev button clicked");
    prevItem();
    
}

function nextItem() {
    if (currentlyPlaying<(totalNumber-1)) {
        currentlyPlaying++;
    } else {
        currentlyPlaying = 0;
    }
    populateText();
}
function prevItem() {
    if (currentlyPlaying == 0) {
        currentlyPlaying = totalNumber-1;
    } else {
        currentlyPlaying--;
    }
    populateText();
}

function populateText() {
    trace("THIS IS THE MEDIA:"+currentlyPlaying);
    }
populateText();

stop();

XML

<medias>
<theMedia type="mp3 file">
    <title>This is the title</title>
    <artist>This is the artist</artist>
    <thefile>file.mp3</thefile>
</theMedia>

<theMedia type="mp3 file">
    <title>This is the title2</title>
    <artist>This is the artist2</artist>
    <thefile>file2.mp3</thefile>
</theMedia>
</medias>