UpdateAccountScreen.as 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import flash.external.*;
  2. import gfx.controls.TextInput;
  3. import gfx.controls.Button;
  4. import gfx.controls.CheckBox;
  5. import gfx.data.dataProvider;
  6. import gfx.controls.DropdownMenu;
  7. // Please wait
  8. // get account details: Client_GetAccountDetails
  9. // fill in fields
  10. // Enable update account button
  11. // on press, save details
  12. class Screens.UpdateAccountScreen extends Screen
  13. {
  14. private var firstName:TextInput;
  15. private var middleName:TextInput;
  16. private var lastName:TextInput;
  17. private var homeAddress1:TextInput;
  18. private var homeAddress2:TextInput;
  19. private var homeCity:TextInput;
  20. private var homeState:TextInput;
  21. private var homeZipCode:TextInput;
  22. private var billingAddress1:TextInput;
  23. private var billingAddress2:TextInput;
  24. private var billingCity:TextInput;
  25. private var billingState:TextInput;
  26. private var billingZipCode:TextInput;
  27. private var emailAddress:TextInput;
  28. private var password:TextInput;
  29. private var passwordRecoveryQuestion:TextInput;
  30. private var passwordRecoveryAnswer:TextInput;
  31. private var caption1:TextInput;
  32. private var caption2:TextInput;
  33. private var ageInDays:TextInput;
  34. private var handle:TextInput;
  35. private var race:TextInput;
  36. private var homeCountry:TextInput;
  37. private var billingCountry:TextInput;
  38. private var sex_male:CheckBox;
  39. private var updateAccountButton:Button;
  40. public function UpdateAccountScreen()
  41. {
  42. ConsoleWindow.Trace("Constructing UpdateAccountScreen");
  43. mScreenId = ScreenID.UPDATE_ACCOUNT;
  44. mScreenTabId = ScreenTab.ID_PROFILE;
  45. }
  46. public function VOnFinishedLoading():Void
  47. {
  48. //updateAccountButton.visible=false;
  49. //Add click event for buttons
  50. updateAccountButton.addEventListener("click", this, "f2c_UpdateAccount");
  51. //Add callbacks for C++
  52. ExternalInterface.addCallback("c2f_UpdateAccountResult", this, c2f_UpdateAccountResult);
  53. // Do not change the order the parameters are passed in as
  54. //ExternalInterface.call("f2c_GetAccountDetails");
  55. //ExternalInterface.addCallback("c2f_GetAccountDetailsResult", this, c2f_GetAccountDetailsResult);
  56. super.VOnFinishedLoading();
  57. }
  58. /*
  59. function c2f_GetAccountDetailsResult( resultIdentifier:String, firstNameParam:String, middleNameParam:String, lastNameParam:String, raceParam:String,
  60. sex_maleParam:Boolean, homeAddress1Param:String, homeAddress2Param:String, homeCityParam:String, homeStateParam:String,
  61. homeCountryParam:String, homeZipCodeParam:String, billingAddress1Param:String, billingAddress2Param:String,
  62. billingCityParam:String, billingStateParam:String, billingCountryParam:String, billingZipCodeParam:String,
  63. emailAddressParam:String, passwordParam:String, passwordRecoveryQuestionParam:String, passwordRecoveryAnswerParam:String,
  64. caption1Param:String, caption2Param:String, ageInDaysParam:Number ):Void
  65. {
  66. ConsoleWindow.Trace( "UpdateAccountScreen.ServerSetAccountInfo()... " + resultIdentifier );
  67. switch (resultIdentifier)
  68. {
  69. case "SUCCESS":
  70. {
  71. firstName.text = firstNameParam;
  72. middleName.text = middleNameParam;
  73. lastName.text = lastNameParam;
  74. race.text = raceParam;
  75. sex_male.selected = sex_maleParam;
  76. homeAddress1.text = homeAddress1Param;
  77. homeAddress2.text = homeAddress2Param;
  78. homeCity.text = homeCityParam;
  79. homeState.text = homeStateParam;
  80. homeCountry.text = homeCountryParam;
  81. homeZipCode.text = homeZipCodeParam;
  82. billingAddress1.text = billingAddress1Param;
  83. billingAddress2.text = billingAddress2Param;
  84. billingCity.text = billingCityParam;
  85. billingState.text = billingStateParam;
  86. billingCountry.text = billingCountryParam;
  87. billingZipCode.text = billingZipCodeParam;
  88. emailAddress.text = emailAddressParam;
  89. password.text = passwordParam;
  90. passwordRecoveryQuestion.text = passwordRecoveryQuestionParam;
  91. passwordRecoveryAnswer.text = passwordRecoveryAnswerParam;
  92. caption1.text = caption1Param;
  93. caption2.text = caption2Param;
  94. ageInDays.text = String(ageInDaysParam);
  95. updateAccountButton.visible=true;
  96. break;
  97. }
  98. case "DATABASE_CONSTRAINT_FAILURE":
  99. ConsoleWindow.Trace( "Can't find the logged in user in the database for some reason" );
  100. break;
  101. }
  102. }*/
  103. function f2c_UpdateAccount():Void
  104. {
  105. // Do not change the order the parameters are passed in as
  106. ExternalInterface.call("f2c_UpdateAccount",
  107. [ firstName.text, middleName.text, lastName.text, race.text, sex_male.selected, homeAddress1.text, homeAddress2.text, homeCity.text, homeState.text,
  108. homeCountry.text, homeZipCode.text, billingAddress1.text, billingAddress2.text, billingCity.text, billingState.text, billingCountry.text, billingZipCode.text,
  109. emailAddress.text, password.text, passwordRecoveryQuestion.text, passwordRecoveryAnswer.text, caption1.text, caption2.text, ageInDays.text
  110. ]);
  111. // This may take a while, show a waiting screen until we get c2f_UpdateAccountResult
  112. //ExternalInterface.call("f2c_GetAccountDetails");
  113. }
  114. function c2f_UpdateAccountResult(resultIdentifier:String)
  115. {
  116. switch (resultIdentifier)
  117. {
  118. case "DATABASE_CONSTRAINT_FAILURE":
  119. // Can't find the logged in user in the database for some reason
  120. break;
  121. case "SUCCESS":
  122. //_root.gotoAndPlay("LoggedIn");
  123. LobbyInterface.Instance.ShowScreen( ScreenID.LOGGED_IN );
  124. // Done
  125. }
  126. if ( resultIdentifier != "SUCCESS" )
  127. {
  128. LobbyInterface.Instance.CreateMessageBox( resultIdentifier );
  129. }
  130. }
  131. }
粤ICP备19079148号