Sending data to PhP script (help with AS2-AS3 conversion)

I have a project that will take and XML string and send it to a PhP script that will stores it in a .CSV . The code navigates the browser to the php file which then automatically navigates the user to a debreifing page. I took a colleagues AS2 script and tried to translate it to AS3. Here are the two codes.

 getURL(parsefilename, "_self");
  datastring = datastring +  "</VARIABLES>";
  var myXML:XML = new XML(datastring);
  myXML.contentType = "text/xml";
  myXML.send(parsefilename, "_self");


var dataStringXML:XML = new XML(dataString);
var xmlResponse:XML;
var xmlURLReq:URLRequest = new URLRequest(parsefilename); = dataStringXML;
xmlURLReq.contentType = "text/xml";
xmlURLReq.method = URLRequestMethod.POST;
var xmlSendLoad:URLLoader = new URLLoader();
xmlSendLoad.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
navigateToURL(xmlURLReq, "_self")
function onComplete(evt:Event):void {
    try {
        xmlResponse = new XML(;
        removeEventListener(Event.COMPLETE, onComplete);
        removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
    } catch (err:TypeError) {
        trace("Parser Error " + err.message);
function onIOError(evt:IOErrorEvent):void {
   trace("An error occurred when attempting to load the XML.
" + evt.text);

The biggest problem I am having currently is that the CSV is showing two entries everytime the code executes. It works when I put the navtourl function in the oncomplete (i did this thinking i want to nav after all the code has finished), but then it never nav’s.

Any tips or suggestions are appreciated. My code is the result of a lot of forum reading and trial and error, so I dont know a lot about how it works. There is probably unneeded stuff and the like. If anyone is feeling especially helpful and want to suggest a more lean script I would love that.