| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import flash.external.*;
- import gfx.controls.TextInput;
- import gfx.controls.Button;
- class Screens.EnterCDKeyScreen extends Screen
- {
- private var enterCdKeyOKButton:Button;
- private var cancelButton:Button;
- private var cdKeyEditBox:TextInput;
- private var tfFailedMsg:TextField;
-
- public function EnterCDKeyScreen()
- {
- ConsoleWindow.Trace("Constructing EnterCDKeyScreen");
-
- mScreenId = ScreenID.ENTER_CD_KEY;
- mScreenTabId = ScreenTab.ID_CD_KEY;
- tfFailedMsg._visible = false;
- }
-
- public function VOnFinishedLoading():Void
- {
- //Add click event for buttons
- enterCdKeyOKButton.addEventListener("click", this, "f2c_CheckCDKey");
- cancelButton.addEventListener("click", this, "Cancel");
-
- //Add callbacks for C++
- ExternalInterface.addCallback("c2f_CheckCDKeyResult", this, c2f_CheckCDKeyResult);
-
- super.VOnFinishedLoading();
- }
-
- public function f2c_CheckCDKey():Void
- {
- tfFailedMsg._visible = false;
- ConsoleWindow.Trace("cdKeyEditBox.text = " + cdKeyEditBox.text);
- ExternalInterface.call("f2c_CheckCDKey", cdKeyEditBox.text);
- }
-
- public function Cancel():Void
- {
- ConsoleWindow.Trace("EnterCDKeyScreen calling login screen");
- LobbyInterface.Instance.ShowScreen( ScreenID.LOGIN );
- }
- public function c2f_CheckCDKeyResult(reasonIdentifier:String, userUsedBy:String, activationDate:String, wasStolen:Boolean, usable:Boolean):Void
- {
- switch (reasonIdentifier)
- {
- case "SUCCESS":
- if (usable==true)
- {
- // if usable==true, we're ok
- ConsoleWindow.Trace("RegisterAccount?");
- //_root.gotoAndPlay("RegisterAccount");
- LobbyInterface.Instance.ShowScreen( ScreenID.REGISTER_ACCOUNT_PERSONAL );
- }
- else if (wasStolen==true)
- {
- ConsoleWindow.Trace("account stolen?");
- // If wasStolen==true, this cd key was stolen. Display appropriate error message and ask user to reenter
- }
- else
- {
- ConsoleWindow.Trace("cd key already in used");
- // CD key already used. Display appropriate error message and ask user to reenter
- }
- break;
- case "CDKey_GetStatus_TITLE_NOT_IN_USE":
- // Internal error, just display bad title
- break;
- case "CDKey_GetStatus_UNKNOWN_CD_KEY":
- tfFailedMsg.text = "Unknown CD KEY";
- //tfFailedMsg._visible = true;
- // Most common case, CD key was mistyped. Display appropriate error message and ask user to reenter
- break;
- case "REQUIRED_TEXT_IS_EMPTY":
- tfFailedMsg.text = "PLEASE ENTER CD KEY";
- //tfFailedMsg._visible = true;
- // Field was blank
- break;
- }
-
- if ( reasonIdentifier != "SUCCESS" )
- {
- LobbyInterface.Instance.CreateMessageBox( reasonIdentifier );
- }
- }
- }
|