User Guide

282 Chapter 11: Working with External Data
//(optional) Create two text fields for status/debugging
//status_txt.text = this.firstChild.attributes.status;
//debug_txt.text = this.firstChild;
switch (this.firstChild.attributes.status) {
case 'OK' :
_global.session = this.firstChild.attributes.session;
trace(_global.session);
gotoAndStop("welcome");
break;
case 'FAILURE' :
gotoAndStop("loginfailure");
break;
default :
// this should never happen
trace("Unexpected value received for STATUS.");
}
} else {
// trace(“an error occurred.”);
}
};
// this function triggers when the login_btn is clicked
login_btn.onRelease = function() {
var loginXML:XML = new XML();
//create XML formatted data to send to the server
var loginElement:XMLNode = loginXML.createElement("login");
loginElement.attributes.username = username_txt.text;
loginElement.attributes.password = password_txt.text;
loginXML.appendChild(loginElement);
//send the XML formatted data to the server
loginXML.sendAndLoad("http://www.flash-mx.com/mm/main.cfm", loginReplyXML);
};