Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- See sample attached.
- function submitTicketXml() {
- trace("submitTicketXml");
- //compose Ticket xml file send to server receive response
- resetTicketTextFields();
- runners = runnerSelect;
- //Test this
- //bet = amountSelect;
- trace("_level0.bet_screen_mc.amounts_mc.amountText :"+_level0.bet_screen_mc.amounts_mc.amountText);
- bet = _level0.bet_screen_mc.amounts_mc.amountText;
- race_id = raceIdSelect;
- //verify ticket info
- if (verifyTicketInfo()) {
- //generate Ticket xml to send to validateTicket
- _global.myXML = new XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- // var xmlVernode:XMLNode = _global.myXML.createElement("<?xml version=""1.0"" encoding=""UTF-8""?>");
- var wagernode:XMLNode = _global.myXML.createElement("wager");
- //
- var license_accountnode:XMLNode = _global.myXML.createElement("license_account");
- var license_playernode:XMLNode = _global.myXML.createElement("license_player");
- var wager_profilenode:XMLNode = _global.myXML.createElement("wager_profile");
- var ticketnode:XMLNode = _global.myXML.createElement("ticket");
- var textnode:XMLNode = _global.myXML.createTextNode("descr here");
- //
- //_global.myXML.appendChild(xmlVernode);
- _global.myXML.appendChild(wagernode);
- wagernode.appendChild(license_accountnode);
- wagernode.appendChild(license_playernode);
- wagernode.appendChild(wager_profilenode);
- wagernode.appendChild(ticketnode);
- ticketnode.appendChild(textnode);
- //
- _global.myXML.firstChild.attributes.id = "2";
- _global.myXML.firstChild.attributes.license_reference = "1";
- _global.myXML.firstChild.firstChild.attributes.password = "gertner";
- _global.myXML.firstChild.firstChild.attributes.username = "rgertner";
- _global.myXML.firstChild.firstChild.nextSibling.attributes.id = "xxxx";
- _global.myXML.firstChild.firstChild.nextSibling.attributes.balance = "99.00";
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.attributes.id = "1";
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.boxed = boxed;
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.bet = Math.round(bet);
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.runners = runners;
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.bet_type = _global.bet_type;
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.race_id = race_id;
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_discounted = "-";
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_actual = "-";
- _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_estimated = "-";
- trace("myXML to send is : "+myXML);
- //trace("*****************************");
- /*
- <?xml version="1.0"?>
- <wager id="1" license_reference="1">
- <license_account username="rgertner" password="rgertner"/>
- <license_player id="xxxx" balance="99.00"/>
- <wager_profile id="1"/>
- <ticket cost_estimated="999.0" cost_actual="0.00" cost_discounted="0.00" race_id="1" bet_type="2" runners="1,2" bet="2" boxed="0">descr here</ticket>
- </wager>
- reply:
- <?xml version="1.0" encoding="UTF-8"?>
- <wager_response page_id="1175101304234">
- <balance license="0" player="99.0" />
- <ticket id="0" status="0">
- <description>Rainbow 2007-03-28 Race 1 100.0 Win 1,2</description>
- <ticket_cost actual="200.0" estimated="200.0" />
- <ticket_parts>
- <part bet_type="1" cost="100.0" id="0" runners="1" status="0" />
- <part bet_type="1" cost="100.0" id="0" runners="2" status="0" />
- </ticket_parts>
- </ticket>
- </wager_response>
- */
- _global.myReply_xml = new XML();
- _global.myReply_xml.ignoreWhite = true;
- _global.myReply_xml.onLoad = function(success) {
- //trace("_global.myReplyOnLoad running");
- if (success) {
- //trace(myReply_xml);
- //test = "THIS IS RESPONSE : "+_global.myReply_xml;
- _level0.ticket_mc.confirm_btn.enabled = true;
- _level0.ticket_mc.confirm_btn.useHandCursor = true;
- _root.xmlLoading._visible = false;
- //switching because we are calling this from two different places
- switch (_global.ticketConfirm) {
- case true :
- _level0.ticket_mc.gotoAndStop(2);
- _global.ticketConfirm = false;
- break;
- case false :
- _level0.ticket_mc._visible = true;
- _level0.ticket_mc.gotoAndStop(1);
- break;
- default :
- trace("Specify _global.ticketConfirm");
- break;
- }
- for (var n = 0; n<myReply_xml.firstChild.childNodes.length; n++) {
- if (myReply_xml.firstChild.childNodes[n].nodeName == "msg") {
- wagMessage = myReply_xml.firstChild.childNodes[n].firstChild;
- _level0.ticket_mc.wagMessage = wagMessage;
- }
- //
- if (myReply_xml.firstChild.childNodes[n].nodeName == "balance") {
- balance = myReply_xml.firstChild.childNodes[n].attributes.player;
- _level0.ticket_mc.balance = balance;
- }
- if (myReply_xml.firstChild.childNodes[n].nodeName == "ticket") {
- ticket_status = myReply_xml.firstChild.childNodes[n].attributes.status;
- if (ticket_status != 0) {
- //ticket has a problem , disable confirm
- _level0.ticket_mc.confirm_btn.enabled = false;
- }
- //reformat ticket
- ticket_bet_amount = myReply_xml.firstChild.childNodes[n].attributes.bet_amount;
- ticket_bet_type = myReply_xml.firstChild.childNodes[n].attributes.bet_type;
- ticket_runners = myReply_xml.firstChild.childNodes[n].attributes.runners;
- _level0.ticket_mc.runners=ticket_runners;
- _level0.ticket_mc.bet_type=ticket_bet_type;
- _level0.ticket_mc.bet_amount=ticket_bet_amount;
- //////////////////
- license_reference = myReply_xml.firstChild.childNodes[n].attributes.license_reference;
- _level0.ticket_mc.reference = license_reference;
- race = myReply_xml.firstChild.childNodes[n].firstChild;
- if (race != null) {
- track_name = race.attributes.track_name;
- date = race.attributes.date;
- card_no = race.attributes.card_no;
- race_no = race.attributes.race_no;
- _level0.ticket_mc.date = date;
- _level0.ticket_mc.card_no=card_no;
- _level0.ticket_mc.race_no=race_no;
- _level0.ticket_mc.track_name=track_name;
- }
- description = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.firstChild;
- if (description != null) {
- _level0.ticket_mc.description = description;
- }
- cost_estimated = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.attributes.estimated;
- _level0.ticket_mc.cost = cost_estimated;
- //number of bets:
- if (myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nodeName=="ticket_parts")
- {
- bet_num=myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.childNodes.length;
- _level0.ticket_mc.bet_num = bet_num;
- }
- else {
- trace("Ticket_Parts not found in xml");
- _level0.ticket_mc.confirm_btn.enabled = false;
- // bet_num=myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.childNodes.length;
- _level0.ticket_mc.bet_num = "0";
- }
- //tcktMessage = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.firstChild;
- //_level0.ticket_mc.tcktMessage = tcktMessage;
- referenceNo = myReply_xml.firstChild.childNodes[n].attributes.id;
- _level0.ticket_mc.reference = referenceNo;
- //messages
- for (var j = 0; j<myReply_xml.firstChild.childNodes[n].childNodes.length; j++) {
- if (myReply_xml.firstChild.childNodes[n].childNodes[j].nodeName == "msg") {
- //trace("msg "+myReply_xml.firstChild.childNodes[n].childNodes[j].firstChild);
- tcktMessage = myReply_xml.firstChild.childNodes[n].childNodes[j].firstChild;
- //fixing multiline
- tcktMessage=String(tcktMessage).split("\n").join("");
- tcktMessage=String(tcktMessage).split(" ").join(" ");
- _level0.ticket_mc.tcktMessage = tcktMessage;
- }
- }
- }
- //if (myReply_xml.firstChild.childNodes[n].nodeName == "wager_profile"){
- // referenceNo = myReply_xml.firstChild.childNodes[n].attributes.id;
- // _level0.ticket_mc.reference = referenceNo;
- // trace("referenceNo"+referenceNo);
- //}
- //fix it
- ///////////////////////////////////////_root.blockmc._visible = true;
- }
- } else {
- displayError("submitTicketXml - can not load myReply_xml - URL:"+_global.validateWagerUrl);
- }
- };
- _global.myXML.sendAndLoad(_global.validateWagerUrl, _global.myReply_xml);
- }
- }
Add Comment
Please, Sign In to add comment