RegisterAccountScreen2.as 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. import Screens.RegisterAccountScreen;
  8. //Billiing Infomation
  9. class Screens.RegisterAccountScreen2 extends Screen
  10. {
  11. private var billingAddress1:TextInput;
  12. private var billingAddress2:TextInput;
  13. private var billingCity:TextInput;
  14. private var billingState:DropdownMenu;
  15. private var billingZipCode:TextInput;
  16. private var cbSameAsHomeAddress:CheckBox;
  17. private var billingCountry:DropdownMenu;
  18. private var cancelButton:Button;
  19. private var nextButton:Button;
  20. public function RegisterAccountScreen2()
  21. {
  22. ConsoleWindow.Trace("Constructing RegisterAccountScreen2");
  23. mScreenId = ScreenID.REGISTER_ACCOUNT_BILLING;
  24. mScreenTabId = ScreenTab.ID_REGISTRATION;
  25. }
  26. public function VOnFinishedLoading():Void
  27. {
  28. //Add click event for buttons
  29. cancelButton.addEventListener("click", this, "Back");
  30. nextButton.addEventListener("click", this, "Next");
  31. cbSameAsHomeAddress.addEventListener("select", this, "OnToggleHomeAddress");
  32. super.VOnFinishedLoading();
  33. }
  34. public function OnShow():Void
  35. {
  36. billingState.dataProvider = LobbyInterface.Instance.GetScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL )["GetStateList"]();
  37. cbSameAsHomeAddress.selected = false;
  38. if ( LobbyInterface.Instance.IsLoggedIn() )
  39. {
  40. gotoAndStop("Update");
  41. PopulateFromAccountInfo();
  42. }
  43. else
  44. {
  45. gotoAndStop("New");
  46. }
  47. }
  48. public function Next():Void
  49. {
  50. if ( LobbyInterface.Instance.IsLoggedIn() )
  51. {
  52. SaveToAccountInfo();
  53. }
  54. LobbyInterface.Instance.ShowScreen( ScreenID.REGISTER_ACCOUNT_LOGIN );
  55. }
  56. public function Back():Void
  57. {
  58. if ( LobbyInterface.Instance.IsLoggedIn() )
  59. {
  60. SaveToAccountInfo();
  61. }
  62. LobbyInterface.Instance.ShowScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL );
  63. }
  64. public function OnToggleHomeAddress():Void
  65. {
  66. if ( cbSameAsHomeAddress.selected )
  67. {
  68. var registrationScreen = LobbyInterface.Instance.GetScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL );
  69. billingAddress1.text = registrationScreen.GetStreetAddress();
  70. billingAddress2.text = registrationScreen.GetStreetAddress2();
  71. billingCity.text = registrationScreen.GetCity();
  72. billingState.selectedIndex = registrationScreen.GetState();
  73. billingZipCode.text = registrationScreen.GetZipCode();
  74. }
  75. }
  76. public function GetStreetAddress1():String
  77. {
  78. return billingAddress1.text;
  79. }
  80. public function GetStreetAddress2():String
  81. {
  82. return billingAddress2.text;
  83. }
  84. public function GetCity():String
  85. {
  86. return billingCity.text;
  87. }
  88. public function GetSelectedState():String
  89. {
  90. return LobbyInterface.Instance.GetScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL )["GetStateList"]()[billingState.selectedIndex];
  91. }
  92. public function GetZipCode():String
  93. {
  94. return billingZipCode.text;
  95. }
  96. private function PopulateFromAccountInfo():Void
  97. {
  98. billingAddress1.text = AccountInfo.Instance.GetBillingAddress1();
  99. billingAddress2.text = AccountInfo.Instance.GetBillingAddress2();
  100. billingCity.text = AccountInfo.Instance.GetBillingCity();
  101. billingState.selectedIndex = GetIndexFromElement( AccountInfo.Instance.GetBillingState(), RegisterAccountScreen.stateList );
  102. billingZipCode.text = AccountInfo.Instance.GetBillingZipCode();
  103. }
  104. //temporary save, data will get wiped if user exits edit account
  105. private function SaveToAccountInfo():Void
  106. {
  107. AccountInfo.Instance.SetBillingAddress1( billingAddress1.text );
  108. AccountInfo.Instance.SetBillingAddress2( billingAddress2.text );
  109. AccountInfo.Instance.SetBillingCity( billingCity.text );
  110. AccountInfo.Instance.SetBillingState( GetSelectedState() );
  111. AccountInfo.Instance.SetBillingZipCode( billingZipCode.text );
  112. }
  113. }
粤ICP备19079148号