String Manipulation

How’s it going?

I need to do some string manipulation. I need to take a string in the form “artist - song” and extract both the artist and the song and store them in seperate variables.

Any pointers in the right direction?

Thanks,
Saveth

Here is my unsuccessful attempt


function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        songTitle = xmlNode.childNodes[8].childNodes[0];
        
        // TRYING TO ATTEMPT SPLIT
        buyButton = xmlNode.childNodes[8].childNodes[0];
        storedStringArray = buyButton.split("-");
        songName = storedStringArray[storedStringArray.length-1];

        songTitle = songTitle_txt.text.toUpperCase();
        songTitle = songTitle_txt.text.searchReplace(" - ", ": ");
        songTitle_txt.autoSize = true;
        buy_mc._x = songTitle_txt._x+songTitle_txt._width+5;
        buy_mc._y = songTitle_txt._y;
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.crylounge.com/shoutcast.php");

function loadNewXML() {
    xmlData.load("http://www.crylounge.com/shoutcast.php");
}

setInterval(loadNewXML, 10000);

String.prototype.searchReplace = function(str, rep, chr) {
    var t = (chr<0) ? this.substr(chr) : this.substr(0, chr);
    var s = str.length;
    var r = rep.length;
    var p = t.indexOf(str);
    while (p != -1) {
        t = t.substr(0, p)+rep+t.substr(p+s);
        p = t.indexOf(str, p+r);
    }
    return (chr) ? (chr<0) ? this.substr(0, this.length+chr)+t : t+this.substr(chr) : t;
};

buy_mc.buy_btn.onRelease = function() {
    getURL("http://www.google.com", "_blank");
}