NavigationMenu.as 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. 
  2. import gfx.controls.Button;
  3. import mx.transitions.easing.None;
  4. import mx.transitions.Tween;
  5. class NavigationMenu extends MovieClip
  6. {
  7. private var mcLogIn:Button;
  8. private var mcLogOut:Button;
  9. private var mcProfile:Button;
  10. private var mcFriends:Button;
  11. private var mcEmail:Button;
  12. private var mcClan:Button;
  13. private var mcExit:Button;
  14. private var mButtonAnimCt:Number;
  15. private var mButtons:Array; //store buttons in array for sequencial animation
  16. public function NavigationMenu()
  17. {
  18. mButtons = new Array;
  19. }
  20. public function onLoad()
  21. {
  22. mcLogIn.addEventListener("click", this, "OnClickedLogInButton");
  23. mcLogOut.addEventListener("click", this, "OnClickedLogoutButton");
  24. mcProfile.addEventListener("click", this, "OnClickedProfileButton");
  25. mcFriends.addEventListener("click", this, "OnClickedFriendsButton");
  26. mcEmail.addEventListener("click", this, "OnClickedEmailButton");
  27. mcClan.addEventListener("click", this, "OnClickedClanButton");
  28. mcExit.addEventListener("click", this, "OnClickedExitButton");
  29. mButtons.push( mcLogOut );
  30. mButtons.push( mcProfile );
  31. mButtons.push( mcFriends );
  32. mButtons.push( mcEmail );
  33. mButtons.push( mcClan );
  34. mButtons.push( mcExit );
  35. OnPlayerLoggedOut();
  36. }
  37. public function OnClickedLogInButton():Void
  38. {
  39. }
  40. public function OnClickedLogoutButton():Void
  41. {
  42. if ( LobbyInterface.Instance.IsLoggedIn() )
  43. {
  44. LobbyInterface.Instance.GetScreen(ScreenID.LOGGED_IN)["f2c_Logoff"]();
  45. }
  46. }
  47. public function OnClickedProfileButton():Void
  48. {
  49. if ( LobbyInterface.Instance.IsLoggedIn() )
  50. {
  51. LobbyInterface.Instance.ShowScreen( ScreenID.PROFILE );
  52. }
  53. }
  54. public function OnClickedFriendsButton():Void
  55. {
  56. if ( LobbyInterface.Instance.IsLoggedIn() )
  57. {
  58. LobbyInterface.Instance.ShowScreen( ScreenID.FRIENDS );
  59. }
  60. }
  61. public function OnClickedEmailButton():Void
  62. {
  63. if ( LobbyInterface.Instance.IsLoggedIn() )
  64. {
  65. LobbyInterface.Instance.ShowScreen( ScreenID.EMAIL );
  66. }
  67. }
  68. public function OnClickedClanButton():Void
  69. {
  70. if ( LobbyInterface.Instance.IsLoggedIn() )
  71. {
  72. LobbyInterface.Instance.ShowScreen( ScreenID.CLAN_ROOT );
  73. }
  74. }
  75. public function OnClickedExitButton():Void
  76. {
  77. if ( LobbyInterface.Instance.IsLoggedIn() )
  78. {
  79. LobbyInterface.Instance.GetScreen(ScreenID.LOGGED_IN)["f2c_Logoff"]();
  80. }
  81. }
  82. private var mLastTime:Number;
  83. public function OnPlayerLoggedIn():Void
  84. {
  85. mButtonAnimCt = 0;
  86. onEnterFrame = PlayIntroAnimation;
  87. mLastTime = getTimer();
  88. /*
  89. mcLogIn.visible = false;
  90. mcLogOut.visible = true;
  91. mcProfile.visible = true;
  92. mcFriends.visible = true;
  93. mcClan.visible = true;
  94. mcEmail.visible = true;
  95. mcFriends.visible = true;
  96. mcExit.visible = true; */
  97. PlayIntroAnimation();
  98. }
  99. public function PlayIntroAnimation():Void
  100. {
  101. var now:Number = getTimer();
  102. var delta:Number = now - mLastTime;
  103. if ( delta > 100 )
  104. {
  105. mLastTime = now;
  106. //mButtons[mButtonAnimCt]._visible = true;
  107. new Tween( mButtons[mButtonAnimCt], "_alpha", None.easeNone, 0, 100, .5, true );
  108. // new Tween( this, "_alpha", None.easeNone, 0, 100, .5, true );
  109. mButtonAnimCt++;
  110. if ( mButtonAnimCt >= mButtons.length )
  111. {
  112. onEnterFrame = null;
  113. }
  114. }
  115. }
  116. public function OnPlayerLoggedOut():Void
  117. {
  118. /*mcLogOut._alpha = 0;
  119. mcProfile._alpha = 0;
  120. mcFriends._alpha = 0;
  121. mcClan._alpha = 0;
  122. mcEmail._alpha = 0;
  123. mcFriends._alpha = 0;
  124. mcExit._alpha = 0;*/
  125. for ( var i:Number = 0; i < mButtons.length; i++ )
  126. {
  127. new Tween( mButtons[i], "_alpha", None.easeNone, 100, 0, .4, true );
  128. }
  129. /* mcLogIn._alpha = true;
  130. mcLogOut.visible = false;
  131. mcProfile.visible = false;
  132. mcFriends.visible = false;
  133. mcClan.visible = false;
  134. mcEmail.visible = false;
  135. mcFriends.visible = false;
  136. mcExit.visible = false;*/
  137. }
  138. }
粤ICP备19079148号