Parsing xml in a class

hi there, for awhile i’ve been using the gotoandlearn.com mp3player when wanting to provide music in flash, the other day i decided to rewrite into a class. my textfield returns “undefined”, which is frustrating because i know the nodes are being parsed into the loadXML(); method.

the problem i’m having seems to be in the playSong() method, the [COLOR=DarkGreen]sa[/COLOR] Array hasn’t retained the information that had been parsed into it when the loadXML(); method is initialized.

below is the class i’m working with;

thank you to anyone who can help me out here, i’ve been trying to figure it out for a couple of days now, this is a last resort…

[LEFT][COLOR=#993300]class[/COLOR] actionscript.[COLOR=#000000]mp3Player[/COLOR] [COLOR=#993300]extends[/COLOR] [COLOR=#993300]MovieClip[/COLOR] [COLOR=#000000]{[/COLOR]

[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] s:[COLOR=#993300]Sound[/COLOR];[COLOR=#f000f0]*// Setup sound object*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] sa:[COLOR=#993300]Array[/COLOR];[COLOR=#f000f0]*// Array of songs*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] cps:[COLOR=#993300]Number[/COLOR];[COLOR=#f000f0]*// Currently playing song*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] pos:[COLOR=#993300]Number[/COLOR];[COLOR=#f000f0]*// Position of music*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] thisMC;
[COLOR=#993300]public[/COLOR] [COLOR=#993300]var[/COLOR] textPos:[COLOR=#993300]Number[/COLOR];


[COLOR=#993300]public[/COLOR] [COLOR=#993300]function[/COLOR] mp3Player[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    loadXML[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    thisMC = [COLOR=#993300]this[/COLOR];
    sa = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Array[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]

    [COLOR=#f000f0]*// the init method is called on the second frame in the movieclip*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]function[/COLOR] init[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    s.[COLOR=#993300]onSoundComplete[/COLOR] = playSong;
    s.[COLOR=#993300]setVolume[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
    cps = -[COLOR=#000000]1[/COLOR];
    playSong[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    btnActions[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]; 
[COLOR=#000000]}[/COLOR]

    [COLOR=#f000f0]*// load xml*[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]function[/COLOR] loadXML[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#993300]var[/COLOR] [COLOR=#993300]xml[/COLOR]:XML = [COLOR=#993300]new[/COLOR] [COLOR=#993300]XML[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#993300]xml[/COLOR].[COLOR=#993300]ignoreWhite[/COLOR] = [COLOR=#993300]true[/COLOR];
    [COLOR=#993300]xml[/COLOR].[COLOR=#993300]onLoad[/COLOR] = [COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR]success[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]success[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
        [COLOR=#993300]var[/COLOR] nodes:[COLOR=#993300]Array[/COLOR] = [COLOR=#993300]this[/COLOR].[COLOR=#993300]firstChild[/COLOR].[COLOR=#993300]childNodes[/COLOR];
        [COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]var[/COLOR] i = [COLOR=#000000]0[/COLOR]; i<nodes.[COLOR=#993300]length[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{

[/COLOR] sa.[COLOR=#993300]push[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]new[/COLOR] Song[COLOR=#000000]([/COLOR]nodes[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]attributes[/COLOR].[COLOR=#993300]url[/COLOR], nodes[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]attributes[/COLOR].[COLOR=#000000]artist[/COLOR], nodes[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#993300]attributes[/COLOR].[COLOR=#000000]track[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#f000f0]// this trace outputs the correct nodes, so the xml is actually being parsed.[/COLOR]
[COLOR=#993300]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]else[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#993300]this[/COLOR].[COLOR=#000000]trackInfo[/COLOR].[COLOR=#993300]text[/COLOR] = [COLOR=#0000ff]“error”[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];

    [COLOR=#993300]xml[/COLOR].[COLOR=#993300]load[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"songs.xml"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]




[COLOR=#f000f0]*// Play the MP3 File, *[/COLOR]
[COLOR=#993300]public[/COLOR] [COLOR=#993300]function[/COLOR] playSong[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
    
    s = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Sound[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    s.[COLOR=#993300]onSoundComplete[/COLOR] = playSong;
    s.[COLOR=#993300]setVolume[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR];
    thisMC.[COLOR=#000000]mute[/COLOR].[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"on"[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]cps == sa.[COLOR=#000000]length[/COLOR]-[COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        cps = [COLOR=#000000]0[/COLOR];
        s.[COLOR=#993300]loadSound[/COLOR][COLOR=#000000]([/COLOR]sa[COLOR=#000000][[/COLOR]cps[COLOR=#000000]][/COLOR].[COLOR=#000000]earl[/COLOR],[COLOR=#993300]true[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
        s.[COLOR=#993300]loadSound[/COLOR][COLOR=#000000]([/COLOR]sa[COLOR=#000000][[/COLOR]++cps[COLOR=#000000]][/COLOR].[COLOR=#000000]earl[/COLOR],[COLOR=#993300]true[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
    [COLOR=#f000f0]*// this trace will outputs undefined, when it should output an array of nodes....i think*[/COLOR]
            [COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]sa[COLOR=#000000])[/COLOR];
    thisMC.[COLOR=#000000]trackInfo[/COLOR].[COLOR=#993300]text[/COLOR] = sa[COLOR=#000000][[/COLOR]cps[COLOR=#000000]][/COLOR].[COLOR=#000000]artist[/COLOR]+[COLOR=#0000ff]" - "[/COLOR]+sa[COLOR=#000000][[/COLOR]cps[COLOR=#000000]][/COLOR].[COLOR=#000000]track[/COLOR];
    thisMC.[COLOR=#000000]playPause[/COLOR].[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"pause"[/COLOR][COLOR=#000000])[/COLOR];
    textPos = [COLOR=#000000]0[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]
[/LEFT]