ProfileScreen.as 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import gfx.controls.TextArea;
  2. import gfx.controls.Button;
  3. import Screens.RegisterAccountScreen3;
  4. import flash.external.*;
  5. class Screens.ProfileScreen extends Screen
  6. {
  7. private var mcEditProfile:Button;
  8. private var mcSaveProfile:Button;
  9. private var mcChange:Button;
  10. private var mcEditBlockList:Button;
  11. private var mcEditInfo:Button;
  12. private var tfUsername:TextField;
  13. private var mcProfileImage:MovieClip;
  14. private var taAboutMe:TextArea;
  15. private var taActivities:TextArea;
  16. private var taInterests:TextArea;
  17. private var taFavoriteGames:TextArea;
  18. private var taFavoriteMovies:TextArea;
  19. private var taFavoriteBooks:TextArea;
  20. private var taFavoriteQuotes:TextArea;
  21. private var mEditMode:Boolean;
  22. private static var mInstance:ProfileScreen;
  23. public function ProfileScreen()
  24. {
  25. ConsoleWindow.Trace("Constructing ProfileScreen");
  26. mScreenId = ScreenID.PROFILE;
  27. mScreenTabId = ScreenTab.ID_PROFILE;
  28. mInstance = this;
  29. }
  30. public static function get Instance():ProfileScreen { return mInstance; }
  31. public function VOnFinishedLoading():Void
  32. {
  33. //Add click event for buttons
  34. mcEditBlockList.addEventListener("click", this, "OnClickEditBlockList");
  35. mcSaveProfile.addEventListener("click", this, "OnClickSaveProfile");
  36. mcEditProfile.addEventListener("click", this, "OnClickEditProfile");
  37. mcChange.addEventListener("click", this, "OnClickedChange");
  38. mcEditInfo.addEventListener("click", this, "OnClickEditInfo");
  39. //Add callbacks for C++
  40. super.VOnFinishedLoading();
  41. }
  42. public function OnShow():Void
  43. {
  44. if ( !mcProfileImage.mcImageContainer.mcImage )
  45. {
  46. var imageIndex:Number = LobbyInterface.Instance.GetProfileImageIndex();
  47. mcProfileImage.attachMovie( "ProfileImage" + imageIndex, "mcImage", mcProfileImage.getNextHighestDepth() );
  48. }
  49. tfUsername.text = LobbyInterface.Instance.GetUsername();
  50. EnableTextInput( false );
  51. }
  52. public function EnableTextInput( state:Boolean ):Void
  53. {
  54. mcEditProfile._visible = !state;
  55. mcSaveProfile._visible = state;
  56. mEditMode = state;
  57. taAboutMe.disabled = !state;
  58. taActivities.disabled = !state;
  59. taInterests.disabled = !state;
  60. taFavoriteBooks.disabled = !state;
  61. taFavoriteGames.disabled = !state;
  62. taFavoriteMovies.disabled = !state;
  63. taFavoriteQuotes.disabled = !state;
  64. }
  65. public function OnReceivedPlayerInfo():Void
  66. {
  67. taAboutMe.text = AccountInfo.Instance.GetAboutMe();
  68. taActivities.text = AccountInfo.Instance.GetActivities();
  69. taInterests.text = AccountInfo.Instance.GetInterests();
  70. taFavoriteGames.text = AccountInfo.Instance.GetFavoriteGames();
  71. taFavoriteMovies.text = AccountInfo.Instance.GetFavoriteBooks();
  72. taFavoriteBooks.text = AccountInfo.Instance.GetFavoriteMovies();
  73. taFavoriteQuotes.text = AccountInfo.Instance.GetFavoriteQuotes();
  74. }
  75. public function GetAboutMe():String { return taAboutMe.text; }
  76. public function GetActivities():String { return taActivities.text; }
  77. public function GetInterests():String { return taInterests.text; }
  78. public function GetFavoriteGames():String { return taFavoriteGames.text; }
  79. public function GetFavoriteBooks():String { return taFavoriteMovies.text; }
  80. public function GetFavoriteMovies():String { return taFavoriteBooks.text; }
  81. public function GetFavoriteQuotes():String { return taFavoriteQuotes.text; }
  82. public function OnClickSaveProfile():Void
  83. {
  84. EnableTextInput(false);
  85. f2c_UpdateAccount();
  86. }
  87. public function OnClickEditProfile():Void
  88. {
  89. EnableTextInput( true );
  90. }
  91. public function OnClickedChange():Void
  92. {
  93. LobbyInterface.Instance.ShowScreen( ScreenID.CHANGE_PHOTO );
  94. }
  95. public function OnClickEditBlockList():Void
  96. {
  97. LobbyInterface.Instance.ShowScreen( ScreenID.BLOCK_LIST );
  98. }
  99. public function OnClickEditInfo():Void
  100. {
  101. LobbyInterface.Instance.ShowScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL );
  102. }
  103. public function f2c_UpdateAccount():Void
  104. {
  105. // Do not change the order the parameters are passed in as
  106. ExternalInterface.call("f2c_UpdateAccount",
  107. [
  108. AccountInfo.Instance.GetFirstName(), AccountInfo.Instance.GetMiddleName(), AccountInfo.Instance.GetLastName(),
  109. AccountInfo.Instance.GetRace(), AccountInfo.Instance.GetIsMale(), AccountInfo.Instance.GetHomeAddress1(),
  110. AccountInfo.Instance.GetHomeAddress2(), AccountInfo.Instance.GetHomeCity(), AccountInfo.Instance.GetHomeState(),
  111. AccountInfo.Instance.GetHomeCountry(),
  112. AccountInfo.Instance.GetHomeZipCode(),
  113. AccountInfo.Instance.GetBillingAddress1(),
  114. AccountInfo.Instance.GetBillingAddress2(), AccountInfo.Instance.GetBillingCity(), AccountInfo.Instance.GetBillingState(),
  115. AccountInfo.Instance.GetBillingCountry(),
  116. AccountInfo.Instance.GetBillingZipCode(), AccountInfo.Instance.GetEmailAddress(),
  117. AccountInfo.Instance.GetPassword(), AccountInfo.Instance.GetPasswordRecoveryQuestion(), AccountInfo.Instance.GetPasswordRecoveryAnswer(),
  118. "", "",
  119. String( AccountInfo.Instance.GetAgeInDays() ),
  120. GetAboutMe(),
  121. GetActivities(),
  122. GetInterests(),
  123. GetFavoriteGames(),
  124. GetFavoriteMovies(),
  125. GetFavoriteBooks(),
  126. GetFavoriteQuotes()
  127. ]);
  128. }
  129. }
粤ICP备19079148号