XML file reference

i have an xml mp3 plaeyer and i want to add a download button. i’m tring to use the file reference class to do this the problem is when i click the bbutton the save menu comes up but it says undefined and doent downlaod anything. here is my code for my download button


_root["downloadbut"+i].onRelease = function() {
    var url:String = _global.songfile[this.id];
   if(!theFileRef.download(url, _global.songname[this.id].mp3)) {
       trace("dialog box failed to open.");
   } else {
      trace("dialog box has open.");
   }

here is my entire code so you can take a look at it as a whole



stop();


import flash.net.FileReference;

var myListener:Object = new Object();

myListener.onSelect = function(file:FileReference):Void {
    trace("onSelect: " + file.name);
}

myListener.onCancel = function(file:FileReference):Void {
    trace("onCancel");
}

myListener.onOpen = function(file:FileReference):Void {
    trace("onOpen: " + file.name);
}

myListener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

myListener.onComplete = function(file:FileReference):Void {
    trace("onComplete: " + file.name);
}

myListener.onIOError = function(file:FileReference):Void {
    trace("onIOError: " + file.name);
}

var theFileRef:FileReference = new FileReference();
theFileRef.addListener(myListener);


title_txt.autoSize = "left";
timeDisplay_txt.autoSize = "left";
toolTip._visible = false;
var amountLoaded:Number;
var duration:Number;

playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
    if (success) {
        _global.songname = [];
        _global.songband = [];
        _global.songfile = [];
        _global.lyrics = [];
        for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
        _global.songname* = playlist.firstChild.childNodes*.attributes.name;
        _global.songband* = playlist.firstChild.childNodes*.attributes.band;
        _global.songfile* = playlist.firstChild.childNodes*.attributes.file;
        _global.lyrics* = playlist.firstChild.childNodes*.attributes.lyrics;
        attachMovie("butTemp","but"+i,i+50);
        eval("but"+i).id=i;
        _root["but"+i]._x = 5;
        _root["but"+i]._y = 40 + (i*15);
        _root["but"+i].but_txt.text = songname*;
        if (i >= 25){
            _root["but"+i]._x = 160
            _root["but"+i]._y = -5 + (i*15);
        }
        attachMovie("lyrics","lyricbut"+i,i+81);
        eval("lyricbut"+i).id=i;
        _root["lyricbut"+i]._x = 390;
        _root["lyricbut"+i]._y = 40 + (i*15);
        
        attachMovie("download","downloadbut"+i,i+112);
        eval("downloadbut"+i).id=i;
        _root["downloadbut"+i]._x = 455;
        _root["downloadbut"+i]._y = 40 + (i*15);
        
        trace(_global.lyrics*)

        
        _root["but"+i].onRelease = function(){
            clearInterval(timeInterval);
            _root.timeDisplay_txt.text = "00:00/00:00";
            _root.sound_mc.songStarter(songfile[this.id]);
        }
        
        _root["lyricbut"+i].onRelease = function(){
            getURL(_global.lyrics[this.id], "_blank")
        
        }
        

_root["downloadbut"+i].onRelease = function() {
    var url:String = _global.songfile[this.id];
   if(!theFileRef.download(url, _global.songname[this.id].mp3)) {
       trace("dialog box failed to open.");
   } else {
      trace("dialog box has open.");
   }
    
    }
    }
    }
    _root.createEmptyMovieClip("sound_mc", 1);
    _global.song_nr = random(songfile.length);
    _root.sound_mc.songStarter(songfile[song_nr]);
};

function timer(sound_obj) {
    time = sound_obj.position/1000;
    min = Math.floor(time/60);
    min = (min<10) ? "0"+min : min;
    sec = Math.floor(time%60);
    sec = (sec<10) ? "0"+sec : sec;
    timeDisplay_txt.text = min+":"+sec+"/"+totalDuration;
}
function duration (){
    timed = _root.sound_mc.sound_obj.duration/1000;
    mind = Math.floor(timed/60);
    mind = (mind<10) ? "0"+mind : mind;
    secd = Math.floor(timed%60);
    secd = (secd<10) ? "0"+secd : secd;
    totalDuration = mind+":"+secd;
}
MovieClip.prototype.songStarter = function(file) {
    if (this.sound_obj) {
        this.sound_obj.stop();
        delete this.sound_obj;
    }
    this.sound_obj = new Sound(this);
    this.sound_obj.loadSound(file, true);
    this.sound_obj.setVolume(0);
    this.onEnterFrame = function() {
        if (this.sound_obj.position>0) {
            delete this.onEnterFrame;
            timeInterval = setInterval(timer, 1000, this.sound_obj);
            track = this.sound_obj.id3.songname;
            artist = this.sound_obj.id3.artist;
            this._parent.title_txt.text =artist+" - "+track;
        } else {
            this._parent.title_txt.text = "loading...";
        }

    };            
    this.sound_obj.onSoundComplete = function() {
        clearInterval(timeInterval);
        _root.timeDisplay_txt.text = "00:00/00:00";
        (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
        _root.sound_mc.songStarter(songfile[song_nr]);
    };
    this._parent.volume1.dragger.onPress = function() {
        startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
        _root.toolTip._visible = true;
        setInterval(draggableTip,100);
        function draggableTip(){
            _root.toolTip._x = _root._xmouse;
        }
        this.onEnterFrame = function() {
            var p = (this._x/this._parent.volBG._width)*100;
            this._parent._parent.sound_mc.sound_obj.setVolume(p);
            
        };
    };
    this._parent.volume1.dragger.onRelease = function() {
        delete this.onEnterFrame;
        stopDrag();
        
    };
    this._parent.volume1.dragger.onReleaseOutside = function() {
        _root.toolTip._visible = false;
        stopDrag();
        
    };
};

function soundStatus(){
    var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
    _root.loader.loadBar._width = amountLoaded * 260;
    duration = _root.sound_mc.sound_obj.duration;
    position = _root.sound_mc.sound_obj.position;
    _root.playHead._x = position / duration * 272 + 5;
}

btn_play.onRelease = function() {
    clearInterval(timeInterval);
    _root.timeDisplay_txt.text = "00:00/00:00";
    this._parent.sound_mc.songStarter(songfile[song_nr]);
};
btn_stop.onRelease = function() {
    clearInterval(timeInterval);
    _root.timeDisplay_txt.text = "00:00/00:00";
    this._parent.sound_mc.sound_obj.stop();
};
btn_fw.onRelease = function() {
    clearInterval(timeInterval);
    _root.timeDisplay_txt.text = "00:00/00:00";
    (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
    _root.sound_mc.songStarter(songfile[song_nr]);
};
btn_rev.onRelease = function() {
    clearInterval(timeInterval);
    _root.timeDisplay_txt.text = "00:00/00:00";
    (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
    _root.sound_mc.songStarter(songfile[song_nr]);
};
playlist.load("playlist.xml");
setInterval(duration,100);
setInterval(soundStatus,100);

any one have any ideas

thanks
Jake