Hi all,

i made an mp3 player which works fine.. here is the code i'm using

Code:
var jbx:XML = new XML(); 

jbx.ignoreWhite = true; 

var songArray:Array = new Array(); 

var urls:Array = new Array(); 


var titles:Array = new Array(); 


var currentIndex:Number = 0; 

var jukebox:Sound = new Sound(); 




jbx.onLoad = function(success) {
    if (success) {
        songArray = jbx.firstChild.childNodes;
        for (i=0;i<songArray.length;i++) {
            urls.push(songArray[i].attributes.url);
            titles.push(songArray[i].attributes.title);
        }
        jukebox.loadSound(urls[currentIndex],true);
        title_txt.text = titles[currentIndex];
    }
    else
    {
        title_txt.text = "Out of Order. Try again later.";
    }
}

jbx.load("music.xml");


//-------MUSIC PLAYER CONTROLS--------//


var currentPosition:Number = 0; 



var paused:Boolean = false;

stop_btn.onRelease = function() {
    currentPosition = 0;
    jukebox.stop();
    paused = true;
}

play_btn.onRelease = function() {
    if (paused) {
        jukebox.start(currentPosition);
        paused = false;
    }

}

pause_btn.onRelease = function() {
    if (!paused) {
        currentPosition = jukebox.position/1000;
        jukebox.stop();
        paused = true;
    }
    else
    {
        if (currentPosition > 0) {
            jukebox.start(currentPosition);
            paused = false;
        }
    }
}

mute_btn.onRelease = function() {
    if (jukebox.getVolume() > 0) {
        jukebox.setVolume(0);
    }
    else
    {
        jukebox.setVolume(100);
    }
}


//---------NEXT/PREVIOUS BUTTONs-----//
function nextSong() {
    if (songArray[currentIndex +1]) {
        currentIndex++;
    }
    else
    {
        currentIndex = 0;
    }
    jukebox.loadSound(urls[currentIndex],true);
    title_txt.text = titles[currentIndex];
    paused = false;
}

function prevSong() {
    if (currentIndex > 0) {
        currentIndex--;
    }
    else
    {
        currentIndex = songArray.length - 1;
    }
    jukebox.loadSound(urls[currentIndex],true);
    title_txt.text = titles[currentIndex];
    paused = false;
}

next_btn.onRelease = nextSong;
prev_btn.onRelease = prevSong;

jukebox.onSoundComplete = nextSong;
The only problem is i need to build a preload that wait until the sound has been fully loaded, then start playing it..

Any idea how i should start coding this? I've never build a preloader when using XML in flash! If someone can point me in a direction plz.. thank you