Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,240 @@
package createAccountGui
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import gui.DarkenManager;
import loader.MediaHelper;
public class GuiAvatarCreationAssets extends Sprite
{
public var creationWiz:GuiCreateWizard;
public var notifyPopup:MovieClip;
public var tipsPopup:MovieClip;
private var nextBtn:MovieClip;
private var backBtn:MovieClip;
private var playBtn:MovieClip;
private var buyBtnRed:MovieClip;
private var buyBtnGreen:MovieClip;
private var closeBtn:MovieClip;
private var _avatarAssets:MovieClip;
private var _mediaHelper:MediaHelper;
private var _createAccountIlAvatar:Object;
public function GuiAvatarCreationAssets()
{
super();
}
public function initFromWorld(isChoosingOceanAvatars:Boolean, isChoosing:Boolean, avatarTypeToShow:int = -1, skipToNameScreen:Boolean = false, currencyType:int = 0, specialValue:int = -1) : void
{
DarkenManager.showLoadingSpiral(true);
this._createAccountIlAvatar = null;
this._mediaHelper = new MediaHelper();
this._mediaHelper.init(1892,this.onAvatarCarouselLoaded,{
"isChoosingOceanAvatars":isChoosingOceanAvatars,
"isChoosing":isChoosing,
"avatarTypeToShow":avatarTypeToShow,
"skipToNameScreen":skipToNameScreen,
"currencyType":currencyType,
"specialValue":specialValue
});
}
public function initFromAccountCreation(assetMC:MovieClip, createAccountIlAvatar:Object) : void
{
this._avatarAssets = assetMC;
this._createAccountIlAvatar = createAccountIlAvatar;
this.init(false,null);
}
public function destroy() : void
{
this.creationWiz.destroy();
this.creationWiz = null;
removeChild(this._avatarAssets);
this._avatarAssets = null;
}
public function get currAvatar() : MovieClip
{
return this.creationWiz.chooseAnimalScreen.currAvatar;
}
public function get currBG() : String
{
return this.creationWiz.chooseAnimalScreen.currBG;
}
public function get currType() : int
{
return this.creationWiz.chooseAnimalScreen.currType;
}
public function get hasEnoughGems() : Boolean
{
return this.creationWiz.chooseAnimalScreen.hasEnoughGems;
}
public function get currAvatarCost() : int
{
return this.creationWiz.chooseAnimalScreen.currAvatarCost;
}
public function get currAvatarName() : String
{
return this.creationWiz.chooseAnimalScreen.currAvatarName;
}
public function get isCreatingWithoutChoosing() : Boolean
{
return this.creationWiz.chooseAnimalScreen.isCreatingWithoutChoosing;
}
public function get currencyType() : int
{
return this.creationWiz.chooseAnimalScreen.currencyType;
}
public function get currEmailAddress() : String
{
return this.creationWiz.emailScreen.currEmail;
}
public function get emailValidationCallback() : Function
{
return this.creationWiz.emailScreen.emailValidCallback;
}
public function get currEmailSoFar() : String
{
return this.creationWiz.emailScreen.currEmail;
}
public function destroyReloadedItems() : void
{
this.creationWiz.chooseAnimalScreen.destroyReloadedItems();
}
public function loadNameLists() : void
{
this.creationWiz.createANameScreen.loadNameLists();
}
private function onAvatarCarouselLoaded(mc:MovieClip) : void
{
this._avatarAssets = MovieClip(mc.getChildAt(0));
this.init(true,mc.passback);
}
private function init(isInWorld:Boolean, requiredParams:Object) : void
{
var tipsPPLinkTxt:TextField = null;
addChild(this._avatarAssets);
this._avatarAssets.addEventListener("Localization",this.onFrameCompleteEvent,false,0,true);
this.notifyPopup = this._avatarAssets.oopsPopup;
this.notifyPopup.notifyTxt = this._avatarAssets.oopsPopup.bodyTxtOops.oops_txt;
this.notifyPopup.titleTxt = this._avatarAssets.oopsPopup.oops_title_txt;
this.notifyPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.notifyPopupBxHandler,false,0,true);
this.notifyPopup.visible = false;
if(!isInWorld)
{
this.tipsPopup = this._avatarAssets.tipsPopup;
this.tipsPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.tipsPopupBxHandler,false,0,true);
tipsPPLinkTxt = this.tipsPopup.tips_pp_txt;
tipsPPLinkTxt.htmlText = tipsPPLinkTxt.text.replace("Privacy Policy","<a href=\'http://www.animaljam.com/privacy\' target=\'_blank\'><u>Privacy Policy</u></a>");
this.playBtn = this._avatarAssets.play_btn;
this.playBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onPlayBtn,false,0,true);
}
else
{
this.buyBtnRed = this._avatarAssets.buy_btn_red;
this.buyBtnRed.addEventListener(MouseEvent.MOUSE_DOWN,this.onBuyBtn,false,0,true);
this.buyBtnGreen = this._avatarAssets.buy_btn_green;
this.buyBtnGreen.addEventListener(MouseEvent.MOUSE_DOWN,this.onBuyBtn,false,0,true);
this.closeBtn = this._avatarAssets.bx;
this.closeBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose,false,0,true);
}
this.nextBtn = this._avatarAssets.next_btn;
this.nextBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onNextBtn,false,0,true);
this.backBtn = this._avatarAssets.back_btn;
this.backBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBackBtn,false,0,true);
this._avatarAssets.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
this.creationWiz = new GuiCreateWizard(this._avatarAssets,this._createAccountIlAvatar);
this.creationWiz.init(this._avatarAssets,this,false,1,null,true,false,isInWorld);
if(isInWorld)
{
this.creationWiz.step = 1;
this.creationWiz.chooseAnimalScreen.setup(requiredParams.isChoosingOceanAvatars,requiredParams.isChoosing,requiredParams.avatarTypeToShow,requiredParams.skipToNameScreen,requiredParams.currencyType,requiredParams.specialValue);
}
}
private function onFrameCompleteEvent(evt:Event = null) : void
{
if(Boolean(this.creationWiz))
{
this.creationWiz.updateCurrScreen();
}
}
private function notifyPopupBxHandler(m:MouseEvent) : void
{
this.notifyPopup.visible = false;
}
private function tipsPopupBxHandler(m:MouseEvent) : void
{
this.tipsPopup.visible = false;
}
private function onNextBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this.creationWiz.next();
}
private function onBackBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this.creationWiz.prev();
}
private function onPlayBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this.creationWiz.onPlay();
}
private function onBuyBtn(evt:MouseEvent) : void
{
evt.stopPropagation();
this.creationWiz.onPlay();
}
private function onClose(evt:MouseEvent) : void
{
evt.stopPropagation();
this.creationWiz.onClose();
}
private function onPopupDown(evt:MouseEvent) : void
{
evt.stopPropagation();
}
}
}
@@ -0,0 +1,818 @@
package createAccountGui
{
import achievement.AchievementXtCommManager;
import avatar.AvatarUtility;
import avatar.NewWorldAvatar;
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBScreen;
import com.sbi.popup.SBWizard;
import createAccountFlow.CreateAccountGui;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import gui.ItemWindowAvatarSelect;
import gui.LoadingSpiral;
import gui.SBScrollbar;
import gui.UpsellManager;
import gui.WindowGenerator;
import item.Item;
import localization.LocalizationManager;
public class GuiChooseAnimal extends SBScreen
{
private var _chooseScreen:MovieClip;
private var _voBtn:MovieClip;
private var _backBtn:MovieClip;
private var _nextBtn:MovieClip;
private var _playBtn:MovieClip;
private var _itemWindow:MovieClip;
private var _avatarHolder:MovieClip;
private var _currAvatar:MovieClip;
private var _buyBtnGreen:MovieClip;
private var _buyBtnRed:MovieClip;
private var _tag:MovieClip;
private var _amlNameTxt:TextField;
private var _titleText:TextField;
private var _avatarWindows:WindowGenerator;
private var _scrollBar:SBScrollbar;
private var _itemsLoadingSpiral:LoadingSpiral;
private var _currAvatarIconIds:Array;
private var _currAvatarTypes:Array;
private var _oceanOnlyIconIds:Array;
private var _oceanOnlyTypes:Array;
private var _usableAvatarIconIds:Array;
private var _usableAvatarTypes:Array;
private var _currBG:String;
private var _avatarNamesByType:Object;
private var _newAvatarFacilitator:NewWorldAvatar;
private var _currType:int;
private var _avtViewsFlag:int;
private var _myCurrencyCount:int;
private var _currCost:int;
private var _currIndex:int;
private var _isChoosingOceanAvatars:Boolean;
private var _isChoosingFirstNonMember:Boolean;
private var _isFromWorld:Boolean;
private var _hasEnoughGems:Boolean;
private var _wizard:SBWizard;
private var _isCreatingWithoutChoosing:Boolean;
private var _diamondCost:int;
private var _currencyType:int;
private var _scrollYValue:int;
private var _isMovingScreens:Boolean;
private var _registrationPanel:MovieClip;
private var _avatarSelect:MovieClip;
public function GuiChooseAnimal(initLogin:Object, initWizard:SBWizard, isFromWorld:Boolean)
{
this._chooseScreen = isFromWorld ? initLogin.registrationPanel.chooseAnimal : initLogin.registrationPanel.chooseAnimal;
super(this._chooseScreen,initWizard);
this._registrationPanel = MovieClip(this._chooseScreen.parent);
this._avatarSelect = MovieClip(this._chooseScreen.parent.parent);
this._amlNameTxt = this._chooseScreen.animalNameText;
this._itemWindow = this._chooseScreen.itemWindow;
this._titleText = this._chooseScreen.titleText;
this._isFromWorld = isFromWorld;
this._wizard = initWizard;
if(isFromWorld)
{
this._backBtn = initLogin.back_btn;
this._nextBtn = initLogin.next_btn;
this._playBtn = initLogin.play_btn;
this._avatarHolder = initLogin.allAvatars;
this._buyBtnGreen = initLogin.buy_btn_green;
this._buyBtnRed = initLogin.buy_btn_red;
this._tag = this._chooseScreen.tag;
}
else
{
this._voBtn = this._chooseScreen.vo_btn;
this._playBtn = initLogin.play_btn;
this._backBtn = initLogin.back_btn;
this._nextBtn = initLogin.next_btn;
this._avatarHolder = initLogin.allAvatars;
}
}
public function init() : void
{
onEnterFromNext = this.enterFromNext;
onEnterFromPrev = this.enterFromPrev;
onLeaveToPrev = this.leaveToPrev;
onLeaveToNext = this.leaveToNext;
onClose = this.leaveToPrev;
updateScreen = this.updateScreenAssets;
if(!this._isFromWorld)
{
this._playBtn.visible = false;
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
}
else
{
this._buyBtnGreen.visible = false;
this._buyBtnRed.visible = false;
this._tag.visible = false;
}
this._backBtn.visible = false;
this._amlNameTxt.text = "";
this._myCurrencyCount = gMainFrame.clientInfo.gemCount;
this._newAvatarFacilitator = new NewWorldAvatar();
this._usableAvatarIconIds = [];
this._usableAvatarTypes = [];
this._currAvatarIconIds = [];
this._currAvatarTypes = [];
this._avatarNamesByType = [];
this._oceanOnlyIconIds = [];
this._oceanOnlyTypes = [];
this._avtViewsFlag = gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_AVT_VIEWABLE_FLAG);
this._itemsLoadingSpiral = new LoadingSpiral(this._itemWindow,this._itemWindow.width * 0.5,this._itemWindow.height * 0.5);
this._itemsLoadingSpiral.visible = true;
this.setupIcons();
if(!this._isFromWorld && Boolean(CreateAccountGui.vo1Sound))
{
CreateAccountGui.vo1Sound.play();
if(Boolean(CreateAccountGui.vo1Sound.sc))
{
CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
}
override public function destroy() : void
{
if(Boolean(this._avatarWindows))
{
this._avatarWindows.destroy();
this._avatarWindows = null;
}
if(Boolean(this._scrollBar))
{
this._scrollBar.destroy();
this._scrollBar = null;
}
super.destroy();
}
public function destroyReloadedItems() : void
{
if(Boolean(this._avatarWindows))
{
this._avatarWindows.destroy();
this._avatarWindows = null;
}
if(Boolean(this._scrollBar))
{
this._scrollBar.destroy();
this._scrollBar = null;
}
}
public function setup(isChoosingOceanAvatars:Boolean, isChoosing:Boolean, avatarType:int = -1, skipToNameScreen:Boolean = false, currencyType:int = 0, specialValue:int = -1) : void
{
this._isMovingScreens = false;
this._avtViewsFlag = gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_AVT_VIEWABLE_FLAG);
this._currencyType = currencyType;
this.setupIcons(true);
if(currencyType == Item.GEM_CURRENCY)
{
this._myCurrencyCount = gMainFrame.clientInfo.gemCount;
}
else if(currencyType == Item.DIAMOND_CURRENCY)
{
this._myCurrencyCount = gMainFrame.clientInfo.diamondCount;
}
this._isChoosingOceanAvatars = isChoosingOceanAvatars;
this._isChoosingFirstNonMember = isChoosing;
this._nextBtn.visible = true;
this._buyBtnGreen.visible = false;
this._buyBtnRed.visible = false;
this._backBtn.visible = false;
this._isCreatingWithoutChoosing = skipToNameScreen;
if(this._isChoosingOceanAvatars)
{
this._currAvatarIconIds = this._oceanOnlyIconIds;
this._currAvatarTypes = this._oceanOnlyTypes;
}
else
{
this._currAvatarIconIds = this._usableAvatarIconIds;
this._currAvatarTypes = this._usableAvatarTypes;
}
this.pickRandomAvatar(avatarType,specialValue);
this._wizard.creationAssets.creationWiz.step = skipToNameScreen ? 2 : 1;
if(Boolean(this._currAvatar) && Boolean(this._currBG))
{
if(!skipToNameScreen)
{
this.enterFromPrev();
this._nextBtn.visible = true;
this._tag.visible = true;
}
else
{
this._nextBtn.visible = false;
this._tag.visible = false;
}
}
if(!skipToNameScreen)
{
this.createAvatarWindows();
}
}
public function enterFromNext() : void
{
this._registrationPanel.gotoAndPlay("backChooseAnAnimal");
this._currAvatar.gotoAndPlay("backChooseAnAnimal");
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndPlay("backChooseAnAnimal");
if(this._isFromWorld)
{
this._buyBtnGreen.visible = false;
this._buyBtnRed.visible = false;
this._nextBtn.visible = true;
}
this.enterFromBoth();
}
public function enterFromPrev() : void
{
this._registrationPanel.gotoAndStop("intro");
if(Boolean(this._currAvatar))
{
this._currAvatar.gotoAndStop("chooseAnAnimal");
}
if(Boolean(this._currBG))
{
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndPlay("intro");
}
this.enterFromBoth();
}
public function enterFromBoth() : void
{
if(!this._isFromWorld && Boolean(CreateAccountGui.vo1Sound))
{
CreateAccountGui.vo1Sound.play();
if(Boolean(CreateAccountGui.vo1Sound.sc))
{
CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
this._isMovingScreens = false;
if(this._isFromWorld)
{
SBTracker.trackPageview("/game/play/popup/avatarCreation/ChooseAnimal");
}
else
{
CreateAccountGui.trackUserCreateAccountPageChange("ChooseAnimal");
}
}
public function leaveToNext() : Boolean
{
var currDef:Object = null;
if(Boolean(this._nextBtn.isGray))
{
return false;
}
if(!this._isFromWorld)
{
if(Boolean(CreateAccountGui.vo1Sound))
{
CreateAccountGui.vo1Sound.stop();
}
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
if(!gMainFrame.userInfo.isMember)
{
currDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvDefIndexByType(this._currType)];
if(Boolean(currDef.isMemberOnly))
{
if(this._isCreatingWithoutChoosing)
{
if(this._registrationPanel.currentFrameLabel != "chooseAName")
{
this._registrationPanel.gotoAndStop("chooseAName");
}
if(this._currAvatar.currentFrameLabel != "chooseAName")
{
this._currAvatar.gotoAndStop("chooseAName");
}
if(this._avatarSelect.bg[this._currBG + "Bg"].currentFrameLabel != "chooseAName")
{
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndStop("chooseAName");
}
return true;
}
UpsellManager.displayPopup(UpsellManager.ANIMALS,"createMembersOnlyAvatar");
}
else if(AvatarUtility.numNonMemberAvatars() >= 2 && !this._isChoosingFirstNonMember)
{
UpsellManager.displayPopup(UpsellManager.ANIMAL_SLOTS,"buyThirdAvatar");
}
else
{
if(!(this._isChoosingFirstNonMember && currDef.enviroFlag == 2))
{
if(this._isCreatingWithoutChoosing)
{
this._registrationPanel.gotoAndStop("chooseAName");
this._currAvatar.gotoAndStop("chooseAName");
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndStop("chooseAName");
}
else
{
this._registrationPanel.gotoAndPlay("playChooseAName");
this._currAvatar.gotoAndPlay("playChooseAName");
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndPlay("playChooseAName");
}
this._isMovingScreens = true;
return true;
}
new SBOkPopup(this._avatarSelect.parent.parent,LocalizationManager.translateIdOnly(14689));
}
return false;
}
if(this._isCreatingWithoutChoosing)
{
this._registrationPanel.gotoAndStop("chooseAName");
this._currAvatar.gotoAndStop("chooseAName");
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndStop("chooseAName");
}
else
{
this._registrationPanel.gotoAndPlay("playChooseAName");
this._currAvatar.gotoAndPlay("playChooseAName");
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndPlay("playChooseAName");
}
this._isMovingScreens = true;
return true;
}
public function leaveToPrev() : Boolean
{
if(!this._isFromWorld)
{
if(Boolean(CreateAccountGui.vo1Sound))
{
CreateAccountGui.vo1Sound.stop();
}
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
this._newAvatarFacilitator.nameTypeScreenDone();
this._isMovingScreens = true;
return true;
}
public function leaveToBoth() : Boolean
{
return true;
}
public function updateScreenAssets(isCurrentScreen:Boolean = false) : void
{
this._chooseScreen = this._registrationPanel.chooseAnimal;
this._amlNameTxt = this._chooseScreen.animalNameText;
this._itemWindow = this._chooseScreen.itemWindow;
this._titleText = this._chooseScreen.titleText;
if(this._isFromWorld)
{
this._tag = this._chooseScreen.tag;
this._buyBtnGreen = this._avatarSelect.buy_btn_green;
this._buyBtnRed = this._avatarSelect.buy_btn_red;
}
if(isCurrentScreen)
{
this.setupAvatarTextItems();
this.createAvatarWindows();
if(this._isFromWorld)
{
this._buyBtnGreen.visible = false;
this._buyBtnRed.visible = false;
this._tag.visible = true;
}
else
{
this._playBtn.visible = false;
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
this._voBtn = this._chooseScreen.vo_btn;
}
if(!this._isFromWorld && Boolean(CreateAccountGui.vo1Sound))
{
if(Boolean(CreateAccountGui.vo1Sound.sc))
{
this._voBtn.play();
}
}
}
}
public function get currencyType() : int
{
return this._currencyType;
}
public function get isCreatingWithoutChoosing() : Boolean
{
return this._isCreatingWithoutChoosing;
}
public function get currAvatar() : MovieClip
{
return this._currAvatar;
}
public function get currBG() : String
{
return this._currBG;
}
public function get currType() : int
{
return this._currType;
}
public function get hasEnoughGems() : Boolean
{
return this._hasEnoughGems;
}
public function get currAvatarCost() : int
{
return this._diamondCost == -1 ? this._currCost : this._diamondCost;
}
public function get currAvatarName() : String
{
return LocalizationManager.translateIdOnly(this._avatarNamesByType[this._currType]);
}
private function setupIcons(isRecreating:Boolean = false) : void
{
var iconId:int = 0;
var currDef:Object = null;
var creationAvatar:Array = AvatarUtility.creationAvatars;
this._usableAvatarIconIds = [];
this._usableAvatarTypes = [];
this._oceanOnlyIconIds = [];
this._oceanOnlyTypes = [];
for(var i:int = 0; i < creationAvatar.length; i++)
{
try
{
if(Boolean(AvatarUtility.avatarDefInfo && AvatarUtility.avatarDefInfo.length > 0) && Boolean(i < AvatarUtility.avatarDefInfo.length) && Boolean(AvatarUtility.avatarDefInfo[i]))
{
iconId = int(gMainFrame.userInfo.getAvatarDefByAvType(creationAvatar[i].avTypeId).iconMediaId);
currDef = AvatarUtility.avatarDefInfo[i];
if((this._avtViewsFlag & 1 << AvatarUtility.avatarTypes[i] - 1) != 0)
{
if(!this._isFromWorld && (AvatarUtility.isEndangered(currDef.availability) || AvatarUtility.isExtinct(currDef.availability)))
{
continue;
}
this._usableAvatarIconIds.push(iconId);
this._usableAvatarTypes.push(creationAvatar[i].avTypeId);
if(Utility.isOcean(AvatarUtility.avatarDefInfo[i].enviroFlag))
{
this._oceanOnlyIconIds.push(iconId);
this._oceanOnlyTypes.push(creationAvatar[i].avTypeId);
}
}
this._avatarNamesByType[creationAvatar[i].avTypeId] = gMainFrame.userInfo.getAvatarDefByAvType(creationAvatar[i].avTypeId).titleStrRef;
if(Boolean(this._currType) && creationAvatar[i].avTypeId == this._currType)
{
LocalizationManager.translateId(this._amlNameTxt,this._avatarNamesByType[this._currType]);
}
}
}
catch(e:Error)
{
}
}
this._currAvatarIconIds = this._usableAvatarIconIds;
this._currAvatarTypes = this._usableAvatarTypes;
if(!this._isFromWorld && !isRecreating)
{
this.pickRandomAvatar();
this.createAvatarWindows();
}
}
private function pickRandomAvatar(type:int = -1, diamondCost:int = -1) : void
{
var i:int = 0;
if(type == -1)
{
this._currIndex = Math.floor(Math.random() * (this._currAvatarTypes.length - 1 - 0 + 1)) + 0;
type = int(this._currAvatarTypes[this._currIndex]);
}
else
{
for(i = 0; i < this._currAvatarTypes.length; i++)
{
if(this._currAvatarTypes[i] == type)
{
this._currIndex = i;
break;
}
}
}
this._diamondCost = diamondCost;
this._currType = type;
this.setupCurrAvatar();
}
private function createAvatarWindows() : void
{
if(Boolean(this._avatarWindows) && this._avatarWindows.numWindowsCreated > 0)
{
this._itemWindow.addChild(this._avatarWindows);
if(this._isFromWorld)
{
if(Boolean(this._scrollBar))
{
this._scrollYValue = this._scrollBar.scrollYValue;
this._scrollBar.destroy();
this._scrollBar = null;
}
this._scrollBar = new SBScrollbar();
this._scrollBar.init(this._avatarWindows,this._avatarWindows.width,this._avatarWindows.boxHeight * 3 + 2 * 3,10,"scrollbar2",this._avatarWindows.boxHeight + 2,this._scrollYValue,this._avatarWindows.height);
}
return;
}
this._itemsLoadingSpiral.visible = true;
if(Boolean(this._scrollBar))
{
this._scrollYValue = this._scrollBar.scrollYValue;
this._scrollBar.destroy();
this._scrollBar = null;
}
if(Boolean(this._avatarWindows))
{
this._avatarWindows.destroy();
this._avatarWindows = null;
}
this._avatarWindows = new WindowGenerator();
this._avatarWindows.init(3,3,this._currAvatarIconIds.length,2,2,2,ItemWindowAvatarSelect,this._currAvatarIconIds,"",{
"mouseDown":this.winMouseDown,
"mouseOver":this.winMouseOver,
"mouseOut":this.winMouseOut
},{
"forCreation":!this._isFromWorld,
"avTypes":this._currAvatarTypes
},this.onAvatarIconWindowsLoaded,false,false);
this._itemWindow.addChild(this._avatarWindows);
}
private function onAvatarIconWindowsLoaded() : void
{
if(this._isFromWorld && this._scrollBar == null)
{
this._scrollBar = new SBScrollbar();
this._scrollBar.init(this._avatarWindows,this._avatarWindows.width,this._avatarWindows.boxHeight * 3 + 2 * 3,10,"scrollbar2",this._avatarWindows.boxHeight + 2,this._scrollYValue,this._avatarWindows.height);
}
this._itemsLoadingSpiral.visible = false;
if(MovieClip(this._avatarWindows.bg.getChildAt(this._currIndex)).currWindow.currentFrameLabel != "down")
{
MovieClip(this._avatarWindows.bg.getChildAt(this._currIndex)).currWindow.gotoAndStop("down");
}
}
private function winMouseDown(evt:MouseEvent) : void
{
evt.stopPropagation();
if(!this._isMovingScreens && this._currIndex != evt.currentTarget.index)
{
MovieClip(this._avatarWindows.bg.getChildAt(this._currIndex)).deselect();
this._currIndex = evt.currentTarget.index;
this._currType = this._currAvatarTypes[evt.currentTarget.index];
if(evt.currentTarget.currWindow.currentFrameLabel != "down")
{
evt.currentTarget.currWindow.gotoAndStop("down");
}
this.setupCurrAvatar();
}
}
private function setupCurrAvatar() : void
{
var splitData:Array = null;
var currLabels:Array = this._avatarHolder.currentLabels;
for(var i:int = 0; i < currLabels.length; i++)
{
splitData = currLabels[i].name.split("_");
if(splitData[1] == this._currType)
{
this._currBG = splitData[0];
this._avatarHolder.gotoAndStop(this._currBG + "_" + this._currType);
this._currAvatar = this._avatarHolder["avatar" + this._currType];
break;
}
}
if(Boolean(this._currAvatar))
{
this._currAvatar.gotoAndPlay("intro");
this.setupAvatarTextItems();
}
if(Boolean(this._currBG))
{
if(this._avatarSelect.bg.currentFrameLabel != this._currBG)
{
this._avatarSelect.bg.gotoAndStop(this._currBG);
this._avatarSelect.bg[this._currBG + "Bg"].gotoAndPlay("intro");
}
}
}
private function setupAvatarTextItems() : void
{
var avDef:Object = null;
if(Boolean(this._currAvatar))
{
if(Boolean(this._avatarNamesByType[this._currType]))
{
LocalizationManager.translateId(this._amlNameTxt,this._avatarNamesByType[this._currType]);
}
avDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvatarIndexByType(this._currType)];
if(this._isFromWorld)
{
this._currCost = this._diamondCost == -1 ? int(avDef.cost) : this._diamondCost;
if(!this._isChoosingFirstNonMember)
{
this._tag.txt.text = Utility.convertNumberToString(this._currCost);
if(this._myCurrencyCount < this._currCost)
{
this._hasEnoughGems = false;
this._tag.gotoAndStop("red");
this._tag.txt.textColor = "0x800000";
}
else
{
this._hasEnoughGems = true;
this._tag.gotoAndStop("green");
this._tag.textColor = "0xFFFFFFFF";
}
}
else
{
this._hasEnoughGems = true;
LocalizationManager.translateId(this._tag.txt,11176);
}
}
if(AvatarUtility.isEndangered(avDef.availability))
{
if(this._currType == 13 || this._currType == 16 || this._currType == 26)
{
LocalizationManager.translateId(this._avatarSelect.endangeredSign.txt,11177);
}
else if(this._currType == 6)
{
LocalizationManager.translateId(this._avatarSelect.endangeredSign.txt,14226);
}
else
{
LocalizationManager.translateId(this._avatarSelect.endangeredSign.txt,11178);
}
this._avatarSelect.endangeredSign.visible = true;
}
else
{
this._avatarSelect.endangeredSign.visible = false;
}
if(AvatarUtility.isEndangered(avDef.availability) || AvatarUtility.isExtinct(avDef.availability))
{
this._nextBtn.activateGrayState(true);
if(this._isFromWorld)
{
this._tag.visible = false;
}
}
else
{
this._nextBtn.activateGrayState(false);
if(this._isFromWorld)
{
this._tag.visible = true;
}
}
}
}
private function winMouseOver(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(evt.currentTarget.currWindow.currentFrameLabel == "down")
{
evt.currentTarget.currWindow.gotoAndStop("downMouse");
}
else if(evt.currentTarget.currWindow.currentFrameLabel != "downMouse")
{
evt.currentTarget.currWindow.gotoAndStop("over");
}
AJAudio.playSubMenuBtnRollover();
}
private function winMouseOut(evt:MouseEvent) : void
{
if(Boolean(evt))
{
evt.stopPropagation();
}
if(evt.currentTarget.currWindow.currentFrameLabel == "downMouse")
{
evt.currentTarget.currWindow.gotoAndStop("down");
}
else if(evt.currentTarget.currWindow.currentFrameLabel != "down")
{
evt.currentTarget.currWindow.gotoAndStop("up");
}
}
private function stopVOButton(e:Event) : void
{
if(Boolean(CreateAccountGui))
{
CreateAccountGui.vo1Sound.stop();
}
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
private function voBtnClickHandler(m:MouseEvent) : void
{
m.stopPropagation();
if(CreateAccountGui.vo1Sound.isPlaying)
{
CreateAccountGui.vo1Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
else
{
CreateAccountGui.vo1Sound.play();
if(Boolean(CreateAccountGui.vo1Sound.sc))
{
CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
}
}
}
@@ -0,0 +1,691 @@
package createAccountGui
{
import achievement.AchievementXtCommManager;
import avatar.Avatar;
import avatar.AvatarSwitch;
import avatar.AvatarUtility;
import avatar.INewAvatar;
import avatar.NewWorldAvatar;
import com.sbi.analytics.SBTracker;
import com.sbi.debug.DebugUtility;
import com.sbi.popup.SBOkPopup;
import com.sbi.popup.SBScreen;
import com.sbi.popup.SBWizard;
import com.sbi.popup.SBYesNoPopup;
import createAccountFlow.CreateAccountGui;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import gui.DarkenManager;
import gui.GuiCarousel;
import gui.GuiManager;
import gui.PartyManager;
import gui.SwitchManager;
import gui.UpsellManager;
import item.Item;
import localization.LocalizationManager;
public class GuiCreateAName extends SBScreen
{
private static const AVT_NAMES_1:int = 200;
private static const AVT_NAMES_2:int = 202;
private static const AVT_NAMES_3:int = 203;
private var _createANameScreen:MovieClip;
private var _backBtn:MovieClip;
private var _playBtn:MovieClip;
private var _voBtn:MovieClip;
private var _name1Carousel:GuiCarousel;
private var _name2Carousel:GuiCarousel;
private var _name3Carousel:GuiCarousel;
private var _randomNameLever:MovieClip;
private var _avatarNameTxt:TextField;
private var _titleTxt:TextField;
private var _avatarNameIndexes:Array;
private var _avatarNameChosenIds:Array;
private var _avtNames:Array;
private var _newAvatarFacilitator:INewAvatar;
private var _isFromWorld:Boolean;
private var _isChoosingFirstNonMember:Boolean;
private var _isValid:Boolean;
private var _buyBtnGreen:MovieClip;
private var _buyBtnRed:MovieClip;
private var _nextBtn:MovieClip;
private var _registrationPanel:MovieClip;
private var _isRandomSpin:Boolean;
private var _creationAssets:GuiAvatarCreationAssets;
public function GuiCreateAName(initLogin:Object, initWizard:SBWizard, isFromWorld:Boolean)
{
this._createANameScreen = initLogin.registrationPanel.createAName;
this._backBtn = initLogin.back_btn;
this._playBtn = initLogin.play_btn;
super(this._createANameScreen,initWizard);
this._creationAssets = GuiAvatarCreationAssets(initWizard.creationAssets);
this._registrationPanel = MovieClip(this._createANameScreen.parent);
this._name1Carousel = new GuiCarousel(this._createANameScreen.nameScroller1);
this._name2Carousel = new GuiCarousel(this._createANameScreen.nameScroller2);
this._name3Carousel = new GuiCarousel(this._createANameScreen.nameScroller3);
this._randomNameLever = this._createANameScreen.nameLever;
this._randomNameLever.addEventListener(MouseEvent.MOUSE_DOWN,this.randomLeverMouseDownHandler,false,0,true);
this._avatarNameTxt = this._createANameScreen.aml_name_txt;
this._titleTxt = this._createANameScreen.choose_name_title_txt;
if(isFromWorld)
{
this._nextBtn = initLogin.next_btn;
this._buyBtnGreen = initLogin.buy_btn_green;
this._buyBtnRed = initLogin.buy_btn_red;
}
else
{
this._voBtn = this._createANameScreen.vo_btn;
}
}
public function init(initNewAvFacilitator:Object, isFromWorld:Boolean = false) : void
{
onEnterFromPrev = this.enterFromPrev;
onEnterFromNext = this.enterFromNext;
onLeaveToPrev = this.leaveToPrev;
onLeaveToNext = this.leaveToNext;
onPlay = isFromWorld ? this.leaveToNext : null;
onClose = this.close;
updateScreen = this.updateScreenAssets;
this._newAvatarFacilitator = isFromWorld ? new NewWorldAvatar() : INewAvatar(initNewAvFacilitator);
this._avatarNameTxt.restrict = "A-Za-z0-9 ";
this._avatarNameTxt.maxChars = 23;
this._isFromWorld = isFromWorld;
if(!this._isFromWorld)
{
this._voBtn.stop();
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
}
this._backBtn.visible = false;
this._avatarNameIndexes = [-1,-1,-1];
this._avatarNameChosenIds = [0,0,0];
if(this._avtNames == null)
{
this._avtNames = [-1,-1,-1];
}
if(isFromWorld)
{
GenericListXtCommManager.requestGenericList(AVT_NAMES_1,this.onNamesLoaded);
GenericListXtCommManager.requestGenericList(AVT_NAMES_2,this.onNamesLoaded);
GenericListXtCommManager.requestGenericList(AVT_NAMES_3,this.onNamesLoaded);
}
}
override public function destroy() : void
{
this._createANameScreen = null;
this._name1Carousel.destroy();
this._name1Carousel = null;
this._name2Carousel.destroy();
this._name2Carousel = null;
this._name3Carousel.destroy();
this._name3Carousel = null;
this._newAvatarFacilitator = null;
super.destroy();
}
public function enterFromNext(isChoosingFirstNonMember:Boolean = false) : void
{
this._isChoosingFirstNonMember = isChoosingFirstNonMember;
this._isValid = false;
this._registrationPanel.gotoAndPlay("backChooseAName");
CreateAccountGui.currAvatar().gotoAndPlay("backChooseAName");
MovieClip(this._registrationPanel.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("backChooseAName");
this.enterFromBoth();
}
public function enterFromPrev() : void
{
this._newAvatarFacilitator.hideConnectingMsg();
if(this._isFromWorld)
{
this._nextBtn.visible = false;
this._buyBtnGreen.visible = this._creationAssets.hasEnoughGems;
this._buyBtnRed.visible = !this._buyBtnGreen.visible;
}
this._backBtn.visible = this._isFromWorld ? !this._creationAssets.isCreatingWithoutChoosing : true;
this._isValid = false;
this.enterFromBoth();
}
public function enterFromBoth() : void
{
if(this._newAvatarFacilitator.playSound)
{
if(Boolean(CreateAccountGui.vo2Sound))
{
CreateAccountGui.vo2Sound.play();
if(Boolean(CreateAccountGui.vo2Sound.sc))
{
CreateAccountGui.vo2Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
}
if(this._isFromWorld)
{
SBTracker.trackPageview("/game/play/popup/avatarCreation/CreateAName");
}
else
{
CreateAccountGui.trackUserCreateAccountPageChange("CreateAName");
}
}
public function leaveToNext() : Boolean
{
var avType:int = 0;
var tempAvt:Avatar = null;
var currDef:Object = null;
var avDef:Object = null;
AJAudio.stopRandomLever();
AJAudio.stopNameGenRotationSound();
if(!this._isValid)
{
if(this._isFromWorld)
{
if(gMainFrame.clientInfo.roomType == Utility.ROOMTYPE_PARTY)
{
tempAvt = new Avatar();
tempAvt.init(0,"",this._creationAssets.currType,[]);
if(!PartyManager.canSwitchToAvatar(tempAvt,true))
{
tempAvt.destroy();
tempAvt = null;
return false;
}
}
if(AvatarSwitch.numTotalAvatars >= SwitchManager.NUM_AVATAR_SLOTS)
{
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14690),true,this.onSlotsFullOk);
return true;
}
if(this._creationAssets.isCreatingWithoutChoosing)
{
if(!gMainFrame.userInfo.isMember)
{
currDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvDefIndexByType(this._creationAssets.currType)];
if(Boolean(currDef.isMemberOnly))
{
UpsellManager.displayPopup(UpsellManager.ANIMALS,"createMembersOnlyAvatar");
return false;
}
}
}
if(this._creationAssets.isCreatingWithoutChoosing)
{
if((gMainFrame.userInfo.userVarCache.getUserVarValueById(AchievementXtCommManager.UV_AVT_VIEWABLE_FLAG) & 1 << this._creationAssets.currType - 1) != 0)
{
avDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvatarIndexByType(this._creationAssets.currType)];
new SBYesNoPopup(this._registrationPanel.parent.parent.parent,LocalizationManager.translateIdAndInsertOnly(14782,this._creationAssets.currAvatarName,avDef.cost),true,this.onDiamondShopConfirmBuy);
return false;
}
}
if(!this._isChoosingFirstNonMember && !this._creationAssets.hasEnoughGems)
{
DarkenManager.showLoadingSpiral(true);
if(this._creationAssets.isCreatingWithoutChoosing)
{
this.onCloseNotEnoughGems();
}
else
{
Utility.setupNotEnoughGemsPopup(this._creationAssets.parent,this._creationAssets.currAvatarCost,this._creationAssets.currencyType);
}
return false;
}
if(this._creationAssets.isCreatingWithoutChoosing)
{
GuiManager.showDiamondConfirmation(this._creationAssets.currAvatarCost,this.onDiamondApprovePurchase);
return false;
}
}
avType = this._isFromWorld ? this._creationAssets.currType : CreateAccountGui.currType();
this._newAvatarFacilitator.newAvatarData(avType,this._avatarNameTxt.text,this._avatarNameChosenIds,this.avNameValidCallback,this._isFromWorld ? this._creationAssets.isCreatingWithoutChoosing : false);
}
if(this._isValid)
{
if(Boolean(CreateAccountGui.vo2Sound))
{
CreateAccountGui.vo2Sound.stop();
}
if(!this._isFromWorld)
{
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
this._registrationPanel.gotoAndPlay("playPlayerAccountOne");
CreateAccountGui.currAvatar().gotoAndPlay("playPlayerAccountOne");
MovieClip(this._registrationPanel.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("playPlayerAccountOne");
}
return true;
}
return false;
}
public function leaveToBoth() : Boolean
{
return true;
}
public function leaveToPrev() : Boolean
{
this._backBtn.visible = false;
if(!this._isFromWorld)
{
if(Boolean(CreateAccountGui.vo2Sound))
{
CreateAccountGui.vo2Sound.stop();
}
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
return true;
}
public function loadNameLists() : void
{
GenericListXtCommManager.requestGenericList(AVT_NAMES_1,this.onNamesLoaded,null,this._isFromWorld);
GenericListXtCommManager.requestGenericList(AVT_NAMES_2,this.onNamesLoaded,null,this._isFromWorld);
GenericListXtCommManager.requestGenericList(AVT_NAMES_3,this.onNamesLoaded,null,this._isFromWorld);
}
public function close() : void
{
AvatarSwitch.addAvatarCallback = null;
this._newAvatarFacilitator.nameTypeScreenDone();
}
public function updateScreenAssets(isCurrentScreen:Boolean = false) : void
{
this._createANameScreen = this._registrationPanel.createAName;
this._avatarNameTxt = this._createANameScreen.aml_name_txt;
if(Boolean(this._name1Carousel) && this._name1Carousel.hasLoaded)
{
this._name1Carousel.destroy();
this._name1Carousel = null;
}
this._name1Carousel = new GuiCarousel(this._createANameScreen.nameScroller1);
if(Boolean(this._name2Carousel) && this._name1Carousel.hasLoaded)
{
this._name2Carousel.destroy();
this._name2Carousel = null;
}
this._name2Carousel = new GuiCarousel(this._createANameScreen.nameScroller2);
if(Boolean(this._name3Carousel) && this._name1Carousel.hasLoaded)
{
this._name3Carousel.destroy();
this._name3Carousel = null;
}
this._name3Carousel = new GuiCarousel(this._createANameScreen.nameScroller3);
if(this._avtNames[0] != -1)
{
this.setupNameLists(this._avtNames[0].names,this._avtNames[1].names,this._avtNames[2].names);
}
if(isCurrentScreen || (this._isFromWorld ? Boolean(this._creationAssets.isCreatingWithoutChoosing) : Boolean(false)))
{
this._backBtn = MovieClip(this._registrationPanel.parent).back_btn;
this._playBtn = MovieClip(this._registrationPanel.parent).play_btn;
this._randomNameLever = this._createANameScreen.nameLever;
this._randomNameLever.addEventListener(MouseEvent.MOUSE_DOWN,this.randomLeverMouseDownHandler,false,0,true);
this._titleTxt = this._createANameScreen.choose_name_title_txt;
this._voBtn = this._createANameScreen.vo_btn;
if(this._isFromWorld)
{
this._nextBtn = MovieClip(this._registrationPanel.parent).next_btn;
this._buyBtnGreen = MovieClip(this._registrationPanel.parent).buy_btn_green;
this._buyBtnRed = MovieClip(this._registrationPanel.parent).buy_btn_red;
this._voBtn.visible = false;
this._buyBtnGreen.visible = this._creationAssets.hasEnoughGems;
this._buyBtnRed.visible = !this._buyBtnGreen.visible;
}
else
{
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
if(Boolean(CreateAccountGui.vo2Sound.sc))
{
this._voBtn.play();
}
}
this._backBtn.visible = this._isFromWorld ? !this._creationAssets.isCreatingWithoutChoosing : true;
}
}
private function onNamesLoaded(glId:int, locIds:Array) : void
{
var split:Array = null;
var currName:String = null;
var currIndex:int = 0;
var i:int = 0;
var tempArray:Object = [];
var index:int = -1;
switch(glId)
{
case AVT_NAMES_1:
index = 0;
tempArray = {
"names":[],
"locIds":[]
};
break;
case AVT_NAMES_2:
if(LocalizationManager.isCurrLanguageReversed())
{
tempArray = {
"names":[],
"femNames":[],
"locIds":[]
};
index = 2;
}
else
{
tempArray = {
"names":[],
"types":[],
"locIds":[]
};
index = 1;
}
break;
case AVT_NAMES_3:
if(LocalizationManager.isCurrLanguageReversed())
{
tempArray = {
"names":[],
"types":[],
"locIds":[]
};
index = 1;
}
else
{
tempArray = {
"names":[],
"femNames":[],
"locIds":[]
};
index = 2;
}
}
if(index != -1)
{
for(i = 0; i < locIds.length; i++)
{
if(index == 1)
{
split = LocalizationManager.translateIdOnly(locIds[i]).split("$");
currName = split[0];
currIndex = Utility.findIndexToInsert(tempArray.names,currName);
tempArray.names.splice(currIndex,0,currName);
if(Boolean(split[1]))
{
tempArray.types.splice(currIndex,0,split[1]);
}
else
{
tempArray.types.splice(currIndex,0,"m");
}
}
else if(index == 2)
{
split = LocalizationManager.translateIdOnly(locIds[i]).split("$");
currName = split[0].toLowerCase();
currIndex = Utility.findIndexToInsert(tempArray.names,currName);
tempArray.names.splice(currIndex,0,currName);
if(Boolean(split[1]))
{
tempArray.femNames.splice(currIndex,0,split[1].toLowerCase());
}
else
{
tempArray.femNames.splice(currIndex,0,currName);
}
}
else
{
currName = LocalizationManager.translateIdOnly(locIds[i]);
currIndex = Utility.findIndexToInsert(tempArray.names,currName);
tempArray.names.splice(currIndex,0,currName);
}
tempArray.locIds.splice(currIndex,0,locIds[i]);
}
this._avtNames[index] = tempArray;
}
if(this._avtNames[0] != -1 && this._avtNames[1] != -1 && this._avtNames[2] != -1)
{
this.setupNameLists(this._avtNames[0].names,this._avtNames[1].names,this._avtNames[2].names);
}
}
private function onCloseNotEnoughGems() : void
{
UpsellManager.displayPopup(UpsellManager.EXTRA_DIAMONDS_AS_MEMBER,"extraDiamonds");
}
private function onDiamondApprovePurchase() : void
{
var avType:int = this._isFromWorld ? this._creationAssets.currType : CreateAccountGui.currType();
this._newAvatarFacilitator.newAvatarData(avType,this._avatarNameTxt.text,this._avatarNameChosenIds,this.avNameValidCallback,true);
}
private function onSlotsFullOk(evt:MouseEvent) : void
{
evt.stopPropagation();
SBOkPopup.destroyInParentChain(evt.target.parent);
this.close();
}
private function onDiamondShopConfirmBuy(o:Object) : void
{
var avDef:Object = null;
var currGemsCount:int = 0;
var avType:int = 0;
if(Boolean(o.status))
{
avDef = AvatarUtility.avatarDefInfo[AvatarUtility.findAvatarIndexByType(this._creationAssets.currType)];
currGemsCount = int(gMainFrame.clientInfo.gemCount);
if(currGemsCount < avDef.cost)
{
DarkenManager.showLoadingSpiral(true);
Utility.setupNotEnoughGemsPopup(this._creationAssets.parent,avDef.cost,Item.GEM_CURRENCY);
}
else
{
avType = this._creationAssets.currType;
this._newAvatarFacilitator.newAvatarData(avType,this._avatarNameTxt.text,this._avatarNameChosenIds,this.avNameValidCallback);
}
}
else
{
this.close();
}
}
private function avNameValidCallback(valid:Boolean) : void
{
if(valid)
{
this._isValid = true;
if(super.parentWizard != null)
{
super.parentWizard.next();
}
this._newAvatarFacilitator.nameTypeScreenDone();
}
else
{
DebugUtility.debugTrace("ERROR: Invalid avname?!");
}
}
private function setupNameLists(names1:Array, names2:Array, names3:Array) : void
{
this._name1Carousel.init(names1,this.names1Changed,false,false,null,false,this._avatarNameIndexes[0]);
this._name2Carousel.init(names2,this.names2Changed,false,false,null,false,this._avatarNameIndexes[1]);
this._name3Carousel.init(names3,this.names3Changed,false,false,null,false,this._avatarNameIndexes[2]);
if(this._avatarNameIndexes[0] == -1)
{
this.randomizeNames();
}
}
private function randomizeNames() : void
{
this._name1Carousel.soundsEnabled = false;
this._name2Carousel.soundsEnabled = false;
this._name3Carousel.soundsEnabled = false;
this._name1Carousel.pickRandomItem(true);
this._name2Carousel.pickRandomItem(true);
this._name3Carousel.pickRandomItem(true);
this._name1Carousel.soundsEnabled = true;
this._name2Carousel.soundsEnabled = true;
this._name3Carousel.soundsEnabled = true;
}
private function names1Changed() : void
{
if(Boolean(this._name1Carousel.selectedContentItem) && Boolean(this._name2Carousel.selectedContentItem) && Boolean(this._name3Carousel.selectedContentItem))
{
LocalizationManager.updateToFit(this._avatarNameTxt,this._name1Carousel.selectedContentItem + " " + this._name2Carousel.selectedContentItem + this._name3Carousel.selectedContentItem);
this._avatarNameChosenIds[0] = this._avtNames[0].locIds[this._name1Carousel.contentItemIndex];
this._avatarNameIndexes[0] = this._name1Carousel.contentItemIndex;
}
}
private function names2Changed() : void
{
if(Boolean(this._name1Carousel.selectedContentItem) && Boolean(this._name2Carousel.selectedContentItem) && Boolean(this._name3Carousel.selectedContentItem))
{
LocalizationManager.updateToFit(this._avatarNameTxt,this._name1Carousel.selectedContentItem + " " + this._name2Carousel.selectedContentItem + this._name3Carousel.selectedContentItem);
this._avatarNameChosenIds[1] = this._avtNames[1].locIds[this._name2Carousel.contentItemIndex];
this._avatarNameIndexes[1] = this._name2Carousel.contentItemIndex;
}
if(!this._name2Carousel.soundsEnabled && this._isRandomSpin)
{
this._name2Carousel.soundsEnabled = true;
this._name3Carousel.soundsEnabled = true;
this._isRandomSpin = false;
}
if(Boolean(this._avtNames[2]) && this._name3Carousel.hasLoaded)
{
if(this._avtNames[1].types[this._name2Carousel.contentItemIndex] != "f")
{
if(this._name3Carousel.contentItems != this._avtNames[2].names)
{
this._name3Carousel.contentItems = this._avtNames[2].names;
}
}
else if(Boolean(this._avtNames[2].femNames) && Boolean(this._avtNames[2].femNames[0]) && this._name3Carousel.contentItems != this._avtNames[2].femNames)
{
this._name3Carousel.contentItems = this._avtNames[2].femNames;
}
if(this._name3Carousel.soundsEnabled)
{
this._name3Carousel.soundsEnabled = false;
this._name3Carousel.spinToIndex(this._name3Carousel.contentItemIndex,true);
this._name3Carousel.soundsEnabled = true;
}
else
{
this._name3Carousel.spinToIndex(this._name3Carousel.contentItemIndex,true);
}
}
}
private function names3Changed() : void
{
if(Boolean(this._name1Carousel.selectedContentItem) && Boolean(this._name2Carousel.selectedContentItem) && Boolean(this._name3Carousel.selectedContentItem))
{
LocalizationManager.updateToFit(this._avatarNameTxt,this._name1Carousel.selectedContentItem + " " + this._name2Carousel.selectedContentItem + this._name3Carousel.selectedContentItem);
this._avatarNameChosenIds[2] = this._avtNames[2].locIds[this._name3Carousel.contentItemIndex];
this._avatarNameIndexes[2] = this._name3Carousel.contentItemIndex;
}
if(!this._name3Carousel.soundsEnabled && this._isRandomSpin)
{
this._name3Carousel.soundsEnabled = true;
this._name2Carousel.soundsEnabled = true;
this._isRandomSpin = false;
}
}
private function randomLeverMouseDownHandler(m:MouseEvent) : void
{
if(this._randomNameLever.currentFrameLabel == "_up")
{
this._isRandomSpin = true;
this._name2Carousel.soundsEnabled = false;
this._name3Carousel.soundsEnabled = false;
AJAudio.playRandomLever();
this._randomNameLever.gotoAndPlay("_play");
this._name1Carousel.pickRandomItem();
this._name2Carousel.pickRandomItem();
this._name3Carousel.pickRandomItem();
}
}
private function stopVOButton(e:Event) : void
{
CreateAccountGui.vo2Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
private function enableNext() : void
{
}
private function tipsNeedTxtClickHandler(m:MouseEvent) : void
{
}
private function voBtnClickHandler(m:MouseEvent) : void
{
if(CreateAccountGui.vo2Sound.isPlaying)
{
CreateAccountGui.vo2Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
else
{
CreateAccountGui.vo2Sound.play();
if(Boolean(CreateAccountGui.vo2Sound.sc))
{
CreateAccountGui.vo2Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
}
}
}
@@ -0,0 +1,76 @@
package createAccountGui
{
import com.sbi.popup.SBWizard;
import flash.display.MovieClip;
public class GuiCreateWizard extends SBWizard
{
public const SCREENS_LENGTH:int = 2;
public var playerTagScreen:GuiPlayerTagScreen;
public var emailScreen:GuiEmailScreen;
public var viewAssets:Object;
public var chooseAnimalScreen:GuiChooseAnimal;
public var createANameScreen:GuiCreateAName;
public var createAccountIlAvatar:Object;
public function GuiCreateWizard(view:Object, initCreateAccountIlAvatar:Object)
{
super();
this.viewAssets = view;
this.createAccountIlAvatar = initCreateAccountIlAvatar;
}
override public function init(initWizClip:MovieClip, initGuiAvatarAssets:Object, initVisible:Boolean = true, initStep:int = 1, initScreens:Array = null, initEnabled:Boolean = true, useSeparateScreen:Boolean = false, isInWorld:Boolean = true) : void
{
var screens:Array = null;
creationAssets = initGuiAvatarAssets;
this.chooseAnimalScreen = new GuiChooseAnimal(this.viewAssets,this,isInWorld);
if(isInWorld)
{
this.chooseAnimalScreen.init();
}
this.createANameScreen = new GuiCreateAName(this.viewAssets,this,isInWorld);
this.createANameScreen.init(isInWorld ? this.viewAssets : this.createAccountIlAvatar,isInWorld);
if(isInWorld)
{
screens = new Array(this.chooseAnimalScreen,this.createANameScreen);
}
else
{
this.playerTagScreen = new GuiPlayerTagScreen(isInWorld ? this.viewAssets : this.createAccountIlAvatar,this);
this.playerTagScreen.init();
this.emailScreen = new GuiEmailScreen(isInWorld ? this.viewAssets : this.createAccountIlAvatar,this);
this.emailScreen.init();
screens = new Array(this.chooseAnimalScreen,this.createANameScreen,this.playerTagScreen,this.emailScreen);
}
super.init(initWizClip,initGuiAvatarAssets,initVisible,initStep,screens,initEnabled,useSeparateScreen,isInWorld);
}
override public function destroy() : void
{
this.chooseAnimalScreen.destroy();
this.chooseAnimalScreen = null;
this.createANameScreen.destroy();
this.createANameScreen = null;
if(Boolean(this.playerTagScreen))
{
this.playerTagScreen.destroy();
this.playerTagScreen = null;
}
if(Boolean(this.emailScreen))
{
this.emailScreen.destroy();
this.emailScreen = null;
}
super.destroy();
}
}
}
@@ -0,0 +1,591 @@
package createAccountGui
{
import com.sbi.corelib.Utils;
import com.sbi.popup.SBScreen;
import com.sbi.popup.SBWizard;
import createAccountFlow.CreateAccountGui;
import createAccountFlow.CreateAccountXtCommManager;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
import gui.DarkenManager;
import gui.GuiCheckBox;
import gui.GuiStatusIcon;
public class GuiEmailScreen extends SBScreen
{
public static const MAX_EMAIL_LENGTH:int = 50;
private var _emailTxt:TextField;
private var _confirmTxt:TextField;
private var _emailBar:MovieClip;
private var _confirmBar:MovieClip;
private var _emailSts:MovieClip;
private var _confirmSts:MovieClip;
private var _voBtn:MovieClip;
private var _login:Object;
private const _commonDomains:Array = ["yahoo.com","hotmail.com","gmail.com","comcast.net","sbcglobal.net","att.net","msn.com","microsoft.com","aim.com","charter.net","aol.com","cox.net","live.com","live.ca","verizon.net","xtra.co.nz","shaw.ca","bellsouth.net","roadrunner.com","hotmail.co.uk","yahoo.co.uk","optonline.net","centurylink.net","centurytel.net","mail.com","mac.com","google.com","googlemail.com","compuserve.com","myspace.com","facebook.com","youtube.com","netscape.net","emailaccount.com","earthlink.net","rocketmail.com","broadband.com","ymail.com","supermail.com","junkmail.com","mindspring.com","juno.com","prodigy.net","excite.com","frontiernet.net","frontier.com","frontiernet.net","epix.net","love.com","hellokitty.com","sky.com","pacbell.net","champmail.com","heartmail.com","dragon.com","computer.org","digis.net","yahoo.ca","hotmail.ca","googlemail.co.uk","msn.ca","msn.co.uk","microsoft.co.uk","microsoft.ca","aol.co.uk","live.co.uk","compuserve.co.uk","netscape.ca"];
private const _emailRegExOLD:RegExp = new RegExp(/\A([^;:,\(\)\[\]@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i);
private const _emailRegEx:RegExp = new RegExp(/\w/);
private var _validationPending:Boolean;
private var _continueClicked:Boolean;
private var _validatedEmail:String;
private var _lastCheckedEmail:String;
private var _validatedConfirmEmail:String;
private var _prevConfirmTxt:String;
private var _emailScreen:MovieClip;
private var _playBtn:MovieClip;
private var _nextBtn:MovieClip;
private var _registrationPanel:MovieClip;
private var _emailText:String;
private var _confirmText:String;
private var _emailStsTracking:Object;
private var _confirmStsTracking:Object;
private var _emailKeyUpDelayTimer:Timer;
private var _domainConfirmed:Boolean;
private var _checkBox:GuiCheckBox;
private var _isCheckBoxChecked:Boolean;
private var _isLeavingToPrev:Boolean;
public function GuiEmailScreen(initLogin:Object, initWizard:SBWizard)
{
this._login = initLogin;
this._emailScreen = this._login.accountCreation.registrationPanel.email_popup;
this._registrationPanel = MovieClip(this._emailScreen.parent);
super(this._emailScreen,initWizard);
this._emailTxt = this._emailScreen.emailTxtCont.email_txt;
this._emailTxt.maxChars = MAX_EMAIL_LENGTH;
this._confirmTxt = this._emailScreen.confirmTxtCont.confirm_txt;
this._confirmTxt.maxChars = MAX_EMAIL_LENGTH;
this._emailBar = this._emailScreen.textBarNew;
this._confirmBar = this._emailScreen.confirmTextBar;
this._emailSts = this._emailScreen.emailTxtCont.email_status;
this._confirmSts = this._emailScreen.confirmTxtCont.confirm_status;
this._emailStsTracking = {
"xTracking":false,
"waitTracking":false,
"checkTracking":false
};
this._confirmStsTracking = {
"xTracking":false,
"waitTracking":false,
"checkTracking":false
};
this._checkBox = new GuiCheckBox(this._emailScreen.rulesFrame.agree_box,this.onAgreeChecked);
GuiStatusIcon.initClipOff(this._emailSts,this._emailStsTracking);
GuiStatusIcon.initClipOff(this._confirmSts,this._confirmStsTracking);
this._voBtn = this._emailScreen.vo_btn;
this._playBtn = this._login.accountCreation.play_btn;
this._nextBtn = this._login.accountCreation.next_btn;
this._nextBtn.gotoAndStop(1);
this._isLeavingToPrev = false;
}
public function init() : void
{
onEnterFromPrev = this.enterFromPrev;
onEnterFromNext = this.enterFromNext;
onLeaveToPrev = this.leaveToPrev;
onLeaveToNext = this.leaveToNext;
onPlay = this.onPlayBtn;
updateScreen = this.updateScreenAssets;
this._validationPending = false;
this._continueClicked = false;
this._prevConfirmTxt = "";
this._emailText = "";
this._confirmText = "";
this._emailTxt.addEventListener(KeyboardEvent.KEY_UP,this.emailKeyUpHandler,false,0,true);
this._emailTxt.addEventListener(FocusEvent.FOCUS_OUT,this.onEmailTxtLoseFocus,false,0,true);
this._confirmTxt.addEventListener(KeyboardEvent.KEY_UP,this.confirmKeyUpHandler,false,0,true);
this._emailKeyUpDelayTimer = new Timer(1222);
this._emailKeyUpDelayTimer.addEventListener(TimerEvent.TIMER,this.emailTxtChangeDelayTimerHandler,false,0,true);
this._voBtn.stop();
this._voBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.voBtnClickHandler,false,0,true);
}
override public function destroy() : void
{
this._voBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.voBtnClickHandler);
this._emailKeyUpDelayTimer.stop();
this._emailKeyUpDelayTimer = null;
super.destroy();
}
public function onPlayBtn() : void
{
DarkenManager.showLoadingSpiral(true);
CreateAccountGui.vo5Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
this._login.createNewAccountSetup(CreateAccountGui.currEmailAddress(),CreateAccountGui.emailValidationCallback());
}
public function enterFromNext() : void
{
this._isLeavingToPrev = false;
if(Boolean(this._emailSts["_check"].visible) && Boolean(this._confirmSts["_check"].visible) && this._isCheckBoxChecked)
{
this._playBtn.visible = true;
}
else
{
this._playBtn.visible = false;
}
CreateAccountGui.trackUserCreateAccountPageChange("ParentEmail");
CreateAccountGui.vo4Sound.play();
if(Boolean(CreateAccountGui.vo4Sound.sc))
{
CreateAccountGui.vo4Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVO,false,0,true);
this._voBtn.play();
}
this._nextBtn.visible = false;
CreateAccountGui.hideNotifyPopup();
this._emailKeyUpDelayTimer.reset();
this._emailKeyUpDelayTimer.start();
}
public function enterFromPrev() : void
{
this.enterFromNext();
MovieClip(this._emailScreen.parent).gotoAndPlay("playPlayerAccountTwo");
CreateAccountGui.currAvatar().gotoAndPlay("playPlayerAccountTwo");
MovieClip(this._emailScreen.parent.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("playPlayerAccountTwo");
}
public function enterFromBoth() : void
{
}
public function leaveToPrev() : Boolean
{
this._isLeavingToPrev = true;
this._nextBtn.visible = true;
this._playBtn.visible = false;
CreateAccountGui.vo4Sound.stop();
this._voBtn.stop();
MovieClip(this._emailScreen.parent).gotoAndPlay("backAccountOne");
CreateAccountGui.currAvatar().gotoAndPlay("backAccountOne");
MovieClip(this._emailScreen.parent.parent).bg[CreateAccountGui.currBG() + "Bg"].gotoAndPlay("backAccountOne");
return true;
}
public function leaveToNext() : Boolean
{
CreateAccountGui.vo4Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
CreateAccountGui.hideNotifyPopup();
return this.nextBtnHandler();
}
public function updateScreenAssets(isCurrentScreen:Boolean = false) : void
{
this._emailScreen = this._registrationPanel.email_popup;
this._emailTxt = this._emailScreen.emailTxtCont.email_txt;
this._emailTxt.maxChars = MAX_EMAIL_LENGTH;
this._emailTxt.text = this._emailText;
this._confirmTxt = this._emailScreen.confirmTxtCont.confirm_txt;
this._confirmTxt.maxChars = MAX_EMAIL_LENGTH;
this._confirmTxt.text = this._confirmText;
this._emailBar = this._emailScreen.textBarNew;
this._confirmBar = this._emailScreen.confirmTextBar;
this._emailSts = this._emailScreen.emailTxtCont.email_status;
this._confirmSts = this._emailScreen.confirmTxtCont.confirm_status;
this._checkBox = new GuiCheckBox(this._emailScreen.rulesFrame.agree_box,this.onAgreeChecked);
this._checkBox.init(this._emailScreen.rulesFrame.agree_txt);
this._checkBox.checked = this._isCheckBoxChecked;
GuiStatusIcon.setVisBasedOnTrackers(this._emailSts,this._emailStsTracking);
GuiStatusIcon.setVisBasedOnTrackers(this._confirmSts,this._confirmStsTracking);
this._voBtn = this._emailScreen.vo_btn;
this._playBtn = this._login.accountCreation.play_btn;
this._nextBtn = this._login.accountCreation.next_btn;
this._nextBtn.gotoAndStop(1);
if(isCurrentScreen)
{
this._emailTxt.addEventListener(KeyboardEvent.KEY_UP,this.emailKeyUpHandler,false,0,true);
this._emailTxt.addEventListener(FocusEvent.FOCUS_OUT,this.onEmailTxtLoseFocus,false,0,true);
this._confirmTxt.addEventListener(KeyboardEvent.KEY_UP,this.confirmKeyUpHandler,false,0,true);
if(Boolean(CreateAccountGui.vo4Sound.sc))
{
this._voBtn.play();
}
else
{
this._voBtn.stop();
}
this._voBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.voBtnClickHandler,false,0,true);
if(!this._isLeavingToPrev)
{
if(Boolean(this._emailSts["_check"].visible) && Boolean(this._confirmSts["_check"].visible) && this._isCheckBoxChecked)
{
this._playBtn.visible = true;
}
else
{
this._playBtn.visible = false;
}
}
}
else
{
this._playBtn.visible = false;
}
}
public function get currEmail() : String
{
return this._emailTxt.text;
}
public function stopVO(e:Event) : void
{
if(Boolean(CreateAccountGui))
{
CreateAccountGui.vo4Sound.stop();
}
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
public function emailValidCallback(error:Boolean, invalidEmail:Boolean, isDomainChecked:Boolean = false) : void
{
DarkenManager.showLoadingSpiral(false);
this._validationPending = false;
this._emailSts.visible = true;
this._domainConfirmed = false;
if(invalidEmail)
{
this._validatedEmail = null;
GuiStatusIcon.showX(this._emailSts,this._emailStsTracking);
this._playBtn.visible = false;
if(this._emailTxt.text == "")
{
GuiStatusIcon.initClipOff(this._emailSts,this._emailStsTracking);
this._emailBar.visible = true;
}
else
{
this._emailBar.visible = false;
}
if(!isDomainChecked)
{
this._emailKeyUpDelayTimer.reset();
this._emailKeyUpDelayTimer.start();
}
else
{
this._emailKeyUpDelayTimer.reset();
}
}
else if(!error)
{
if(isDomainChecked)
{
GuiStatusIcon.showCheck(this._emailSts,this._emailStsTracking);
if(this._emailTxt.text == this._confirmTxt.text)
{
this.confirmValidCallback(false);
}
if(Boolean(this._confirmSts["_check"].visible) && this._isCheckBoxChecked)
{
this._playBtn.visible = true;
}
this._validatedEmail = this._emailTxt.text;
this._emailKeyUpDelayTimer.reset();
this._domainConfirmed = true;
}
else
{
this._emailKeyUpDelayTimer.reset();
this._emailKeyUpDelayTimer.start();
GuiStatusIcon.showWait(this._emailSts,this._emailStsTracking);
}
this._emailBar.visible = true;
if(!error && this._emailScreen.currentFrameLabel == "default")
{
this._emailScreen.gotoAndStop("confirm");
}
}
this._continueClicked = false;
}
public function confirmValidCallback(invalidConfirmation:Boolean) : void
{
this._confirmSts.visible = true;
if(invalidConfirmation)
{
this._validatedConfirmEmail = null;
GuiStatusIcon.showX(this._confirmSts,this._confirmStsTracking);
this._playBtn.visible = false;
if(this._confirmTxt.text == "")
{
GuiStatusIcon.initClipOff(this._confirmSts,this._confirmStsTracking);
this._confirmBar.visible = true;
}
else
{
this._confirmBar.visible = false;
}
}
else if(Boolean(this._emailSts["_check"].visible))
{
GuiStatusIcon.showCheck(this._confirmSts,this._confirmStsTracking);
if(this._isCheckBoxChecked)
{
this._playBtn.visible = true;
}
this._confirmBar.visible = true;
this._validatedConfirmEmail = this._confirmTxt.text;
if(this._emailScreen.currentFrameLabel != "rules")
{
this._emailScreen.gotoAndPlay("playRules");
}
if(this._continueClicked && this._isCheckBoxChecked)
{
this.nextBtnHandler();
}
}
this._continueClicked = false;
}
private function onAgreeChecked() : void
{
this._isCheckBoxChecked = this._checkBox.checked;
if(Boolean(this._isCheckBoxChecked) && Boolean(this._emailSts["_check"].visible) && Boolean(this._confirmSts["_check"].visible))
{
this._playBtn.visible = true;
}
else
{
this._playBtn.visible = false;
}
}
private function emailMarkEmptyAsError() : void
{
if(this._emailTxt.text == "")
{
GuiStatusIcon.showX(this._emailSts,this._emailStsTracking);
this._emailSts.visible = true;
this._emailBar.visible = false;
}
}
private function confirmMarkEmptyAsError() : void
{
if(this._confirmTxt.text == "")
{
GuiStatusIcon.showX(this._confirmSts,this._confirmStsTracking);
this._confirmSts.visible = true;
this._confirmBar.visible = false;
}
}
private function emailKeyUpHandler(k:KeyboardEvent) : void
{
var splitEmail:Array = null;
var emailInvalid:Boolean = false;
this._emailText = this._emailTxt.text;
if(this._emailTxt.text == "")
{
GuiStatusIcon.initClipOff(this._emailSts,this._emailStsTracking);
this._emailBar.visible = true;
this._lastCheckedEmail = this._emailTxt.text;
this._validatedEmail = null;
return;
}
if(this._emailTxt.text != this._lastCheckedEmail)
{
this._validationPending = true;
this._lastCheckedEmail = this._emailTxt.text;
splitEmail = this._emailTxt.text.split("@");
if(splitEmail.length > 1 && splitEmail[0].toLowerCase() == this._login.validatedUserName.toLowerCase())
{
parentWizard.prev();
return;
}
emailInvalid = Boolean(!this._emailRegEx["exec"](this._emailTxt.text) || this._emailTxt.text.length > MAX_EMAIL_LENGTH);
this.emailValidCallback(emailInvalid,emailInvalid);
if(this._confirmTxt.text != "")
{
this.confirmKeyUpHandler(null);
}
}
}
private function emailTxtChangeDelayTimerHandler(t:TimerEvent) : void
{
this.onEmailTxtLoseFocus(null);
this._emailKeyUpDelayTimer.reset();
}
private function onEmailTxtLoseFocus(e:FocusEvent) : void
{
var exactDomainMatch:Boolean = false;
var n:int = 0;
var nd:int = 0;
var emailDomain:String = null;
var suggestions:Array = null;
var emailDomainAsArray:Array = null;
var dldist:int = 0;
var emailInvalid:Boolean = Boolean(!this._emailRegEx["exec"](this._emailTxt.text) || this._emailTxt.text.length > MAX_EMAIL_LENGTH);
if(!emailInvalid)
{
exactDomainMatch = false;
n = 0;
nd = int(this._commonDomains.length);
emailDomain = this._emailTxt.text.substr(this._emailTxt.text.indexOf("@") + 1).toLowerCase();
while(n < nd)
{
if(emailDomain == this._commonDomains[n])
{
exactDomainMatch = true;
CreateAccountGui.hideNotifyPopup();
this.emailValidCallback(false,false,true);
break;
}
n++;
}
if(!exactDomainMatch)
{
suggestions = new Array();
emailDomainAsArray = emailDomain.split("");
n = 0;
while(n < nd)
{
dldist = Utils.damerauLevenshteinDistance(emailDomainAsArray,this._commonDomains[n].split(""),64);
if(dldist == 1)
{
suggestions.push(this._commonDomains[n]);
}
n++;
}
if(suggestions.length > 0)
{
CreateAccountGui.showEmailDomainMisspelledWarning(suggestions);
}
else
{
CreateAccountGui.hideNotifyPopup();
}
if(!this._domainConfirmed && !this._validationPending)
{
this._validationPending = true;
GuiStatusIcon.showWait(this._emailSts,this._emailStsTracking);
CreateAccountXtCommManager.sendLoginMXLookup(emailDomain);
}
}
}
}
private function confirmKeyUpHandler(k:KeyboardEvent) : void
{
this._confirmText = this._confirmTxt.text;
if(this._confirmTxt.text == "")
{
GuiStatusIcon.initClipOff(this._confirmSts,this._confirmStsTracking);
this._validatedConfirmEmail = null;
return;
}
if(k != null)
{
CreateAccountGui.hideNotifyPopup();
}
if(this._emailTxt.text == this._confirmTxt.text)
{
this.confirmValidCallback(false);
}
else
{
this.confirmValidCallback(true);
}
}
private function voBtnClickHandler(m:MouseEvent) : void
{
if(CreateAccountGui.vo4Sound.isPlaying)
{
CreateAccountGui.vo4Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
else
{
CreateAccountGui.vo4Sound.play();
if(Boolean(CreateAccountGui.vo4Sound.sc))
{
CreateAccountGui.vo4Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVO,false,0,true);
this._voBtn.play();
}
}
}
private function nextBtnHandler() : Boolean
{
if(this._validationPending || !this._domainConfirmed || !this._isCheckBoxChecked)
{
this._continueClicked = true;
return false;
}
if(this._validatedEmail != null)
{
if(this._validatedConfirmEmail != null)
{
this.stopVO(null);
this._continueClicked = true;
this._validationPending = false;
this._emailKeyUpDelayTimer.reset();
return true;
}
if(this._confirmTxt.text == "")
{
this.confirmMarkEmptyAsError();
}
CreateAccountGui.showMustConfirmMsg();
return false;
}
CreateAccountGui.showUsernameExistsMsg(CreateAccountGui.MSG_ID_EMAIL_INVALID,false);
if(this._emailTxt.text == "")
{
this.emailMarkEmptyAsError();
}
return false;
}
}
}
@@ -0,0 +1,823 @@
package createAccountGui
{
import com.sbi.analytics.SBTracker;
import com.sbi.popup.SBScreen;
import com.sbi.popup.SBWizard;
import createAccountFlow.CreateAccountGui;
import createAccountFlow.CreateAccountXtCommManager;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
import gui.GuiDropdown;
import gui.GuiDropdownDay;
import gui.GuiRadioButtonGroup;
import gui.GuiSoundBtnSubMenu;
import gui.GuiStatusIcon;
public class GuiPlayerTagScreen extends SBScreen
{
public static const NUM_SUGGESTED_NAMES:int = 4;
private var _newBdayMonthDpn:GuiDropdown;
private var _newBdayDayDpn:GuiDropdownDay;
private var _newGenderRbg:GuiRadioButtonGroup;
private var _newPlayerAgeDpn:GuiDropdown;
private var _nameSuggestionsFrame:MovieClip;
private var _nameSugTxts:Array;
private var _userNameKeyUpDelayTimer:Timer;
private var _newUsernameTxt:TextField;
private var _newUsernameBar:MovieClip;
private var _newPasswordTxt:TextField;
private var _newPasswordBar:MovieClip;
private var _animalFrame:MovieClip;
private var _animalFrameAnimalHolder:MovieClip;
private var _activeSelBar1:MovieClip;
private var _activeSelBar2:MovieClip;
private var _activeSelBar3:MovieClip;
private var _activeSelBar4:MovieClip;
private var _backBtn:MovieClip;
private var _nextBtn:MovieClip;
private var _genderAgeSts:MovieClip;
private var _userNameSts:MovieClip;
private var _passWordSts:MovieClip;
private var _tipsNeedTxt:TextField;
private var _privacyPolicyTxt:TextField;
private var _voBtn:MovieClip;
private var _nameTipPopup:MovieClip;
private var _passwordTipPopup:MovieClip;
private var _creation:Object;
private var _playerTagScreen:MovieClip;
private var _validationPending:Boolean;
private var _lastCheckedPlayerTag:String;
private var _continueClicked:Boolean;
private var _numTimesBadUsername:int;
private var _isEmailSameAsUserName:Boolean;
private var _registrationPanel:MovieClip;
private var _selectedBdayMonthIndex:int;
private var _selectedBdayDayIndex:int;
private var _selectedGender:int;
private var _selectedBdayAgeIndex:int;
private var _passwordText:String;
private var _genderAgeTracking:Object;
private var _userNameTracking:Object;
private var _passWordTracking:Object;
public function GuiPlayerTagScreen(initLogin:Object, initWizard:SBWizard)
{
this._creation = initLogin;
this._creation.accountCreation.registrationPanel.gotoAndStop("intro");
this._playerTagScreen = this._creation.accountCreation.registrationPanel.userNamePanel.userNameContainer.signup_wizard.act_popup;
super(this._playerTagScreen,initWizard);
this._registrationPanel = MovieClip(this._creation.accountCreation.registrationPanel);
this._newBdayMonthDpn = new GuiDropdown(this._playerTagScreen.birthday.dropdown_month);
this._newBdayDayDpn = new GuiDropdownDay(this._playerTagScreen.birthday.dropdown_day);
this._newGenderRbg = new GuiRadioButtonGroup(this._playerTagScreen.ageGender.radioGenderBtn);
this._newPlayerAgeDpn = new GuiDropdown(this._playerTagScreen.ageGender.dropdown_age);
this._nameSuggestionsFrame = this._playerTagScreen.NamePopup;
this._newUsernameTxt = this._playerTagScreen.username.pTag_txt;
this._newUsernameBar = this._playerTagScreen.username.textBar1;
this._newPasswordTxt = this._playerTagScreen.password.pswd_txt;
this._newPasswordBar = this._playerTagScreen.password.textBar2;
this._activeSelBar1 = this._playerTagScreen.act_bar_sel1;
this._activeSelBar2 = this._playerTagScreen.act_bar_sel2;
this._activeSelBar3 = this._playerTagScreen.username.act_bar_sel3;
this._activeSelBar4 = this._playerTagScreen.password.act_bar_sel4;
this._tipsNeedTxt = this._playerTagScreen.tips_help_txt;
this._privacyPolicyTxt = this._playerTagScreen.pp_txt;
this._voBtn = this._playerTagScreen.vo_Btn;
this._backBtn = this._creation.accountCreation.back_btn;
this._backBtn.gotoAndStop(1);
this._nextBtn = this._creation.accountCreation.next_btn;
this._nextBtn.gotoAndStop(1);
this._genderAgeSts = this._playerTagScreen.ageGender.genderAge_status;
this._userNameSts = this._playerTagScreen.username.username_status;
this._passWordSts = this._playerTagScreen.password.pswd_status;
this._nameTipPopup = this._playerTagScreen.nameTipPopup;
this._passwordTipPopup = this._playerTagScreen.passwordTipPopup;
}
public function init() : void
{
var nameSugClip:GuiSoundBtnSubMenu = null;
onEnterFromPrev = this.enterFromPrev;
onEnterFromNext = this.enterFromNext;
onLeaveToPrev = this.leaveToPrev;
onLeaveToNext = this.leaveToNext;
updateScreen = this.updateScreenAssets;
this._playerTagScreen.ageGender.visible = false;
this._playerTagScreen.username.visible = false;
this._playerTagScreen.password.visible = false;
this._genderAgeTracking = {
"xTracking":false,
"waitTracking":false,
"checkTracking":false
};
this._userNameTracking = {
"xTracking":false,
"waitTracking":false,
"checkTracking":false
};
this._passWordTracking = {
"xTracking":false,
"waitTracking":false,
"checkTracking":false
};
GuiStatusIcon.initClipOff(this._genderAgeSts,this._genderAgeTracking);
GuiStatusIcon.initClipOff(this._userNameSts,this._userNameTracking);
GuiStatusIcon.initClipOff(this._passWordSts,this._passWordTracking);
this._nameTipPopup.visible = false;
this._passwordTipPopup.visible = false;
this._validationPending = false;
this._continueClicked = false;
this._lastCheckedPlayerTag = "";
this._passwordText = "";
this._newBdayMonthDpn.init(-1.05,0,"-");
this._newBdayDayDpn.init(0.55,0,"-");
this._newPlayerAgeDpn.init(0.55,6,"-");
this._nameSuggestionsFrame.visible = false;
this._nameSuggestionsFrame["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.nameSugCloseBtnMouseDownHandler,false,0,true);
this._nameSugTxts = [];
for(var nsfn:int = 0; nsfn < NUM_SUGGESTED_NAMES; nsfn++)
{
nameSugClip = this._nameSuggestionsFrame["name" + (nsfn + 1)];
this._nameSugTxts[nsfn] = nameSugClip["pTag_txt"];
TextField(this._nameSugTxts[nsfn]).text = "ysername" + nsfn;
nameSugClip.addEventListener(MouseEvent.CLICK,this.nameSugClickHandler,false,0,true);
}
this._userNameKeyUpDelayTimer = new Timer(1222);
this._userNameKeyUpDelayTimer.addEventListener(TimerEvent.TIMER,this.userNameTxtChangeDelayTimerHandler,false,0,true);
this._newUsernameTxt.restrict = "A-Za-z0-9";
this._newUsernameTxt.maxChars = 20;
this._newPasswordTxt.maxChars = 32;
this._activeSelBar1.visible = false;
this._activeSelBar2.visible = false;
this._activeSelBar3.visible = false;
this._activeSelBar4.visible = false;
this._selectedBdayMonthIndex = -1;
this._selectedBdayAgeIndex = -1;
this._selectedBdayDayIndex = -1;
this._selectedGender = -1;
this._newBdayMonthDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler,false,0,true);
this._newBdayDayDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler,false,0,true);
this._newBdayMonthDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler,false,0,true);
this._newBdayDayDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler,false,0,true);
this._newGenderRbg.currRadioButton.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler,false,0,true);
this._newPlayerAgeDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler,false,0,true);
this._newPlayerAgeDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar2FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(Event.CHANGE,this.userNameTxtChangeHandler,false,0,true);
this._newUsernameTxt.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar3FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(KeyboardEvent.KEY_DOWN,this.selBar3FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(FocusEvent.FOCUS_IN,this.selBar3FocusHandler,false,0,true);
this._newPasswordTxt.addEventListener(Event.CHANGE,this.passWordTxtChangeHandler,false,0,true);
this._newPasswordTxt.addEventListener(FocusEvent.FOCUS_IN,this.selBar4FocusHandler,false,0,true);
this._tipsNeedTxt.htmlText = "<a href=\'event:\'><u>" + this._tipsNeedTxt.text + "</u></a>";
this._tipsNeedTxt.addEventListener(TextEvent.LINK,this.tipsNeedTxtClickHandler,false,0,true);
this._privacyPolicyTxt.htmlText = "<a href=\'http://www.animaljam.com/privacy\' target=\'_blank\'><u>" + this._privacyPolicyTxt.text + "</u></a>";
this._voBtn.stop();
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
}
override public function destroy() : void
{
this._newBdayMonthDpn.currDropDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler);
this._newBdayDayDpn.currDropDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler);
this._newBdayMonthDpn.currDropDown.removeEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler);
this._newBdayDayDpn.currDropDown.removeEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler);
this._newGenderRbg.currRadioButton.removeEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler);
this._newPlayerAgeDpn.currDropDown.removeEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler);
this._newPlayerAgeDpn.currDropDown.removeEventListener(FocusEvent.FOCUS_IN,this.selBar2FocusHandler);
this._newUsernameTxt.removeEventListener(Event.CHANGE,this.userNameTxtChangeHandler);
this._newUsernameTxt.removeEventListener(MouseEvent.MOUSE_DOWN,this.selBar3FocusHandler);
this._newUsernameTxt.removeEventListener(KeyboardEvent.KEY_DOWN,this.selBar3FocusHandler);
this._newUsernameTxt.removeEventListener(FocusEvent.FOCUS_IN,this.selBar3FocusHandler);
this._newPasswordTxt.removeEventListener(Event.CHANGE,this.passWordTxtChangeHandler);
this._newPasswordTxt.removeEventListener(FocusEvent.FOCUS_IN,this.selBar4FocusHandler);
this._tipsNeedTxt.removeEventListener(TextEvent.LINK,this.tipsNeedTxtClickHandler);
this._voBtn.removeEventListener(MouseEvent.CLICK,this.voBtnClickHandler);
this._newBdayMonthDpn.destroy();
this._newBdayMonthDpn = null;
this._newBdayDayDpn.destroy();
this._newBdayDayDpn = null;
this._newPlayerAgeDpn.destroy();
this._newPlayerAgeDpn = null;
this._newGenderRbg.destroy();
this._newGenderRbg = null;
this._nameSuggestionsFrame["bx"].removeEventListener(MouseEvent.MOUSE_DOWN,this.nameSugCloseBtnMouseDownHandler);
this._userNameKeyUpDelayTimer.stop();
this._userNameKeyUpDelayTimer = null;
super.destroy();
}
public function enterFromPrev() : void
{
this._playerTagScreen.ageGender.visible = true;
this._playerTagScreen.username.visible = true;
this._playerTagScreen.password.visible = true;
this._numTimesBadUsername = 0;
CreateAccountGui.vo3Sound.play();
if(Boolean(CreateAccountGui.vo3Sound.sc))
{
CreateAccountGui.vo3Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
CreateAccountGui.trackUserCreateAccountPageChange("CreatePlayerAccount");
this.selBar1FocusHandler(null);
this._nextBtn.enabled = false;
CreateAccountGui.hideNotifyPopup();
if(Boolean(this._userNameSts["_check"].visible) && Boolean(this._passWordSts["_check"].visible))
{
this._nextBtn.visible = true;
}
else
{
this._nextBtn.visible = false;
}
}
public function enterFromNext() : Boolean
{
this.enterFromPrev();
if(CreateAccountGui.currEmailAddress().split("@")[0].toLowerCase() == this._newUsernameTxt.text.toLowerCase())
{
this._isEmailSameAsUserName = true;
gMainFrame.stage.focus = this._newUsernameTxt;
CreateAccountGui.showEmailCannotMatchUserName();
this._nextBtn.visible = false;
this._newUsernameBar.visible = false;
GuiStatusIcon.showX(this._userNameSts,this._userNameTracking);
}
return true;
}
public function leaveToNext() : Boolean
{
CreateAccountGui.vo3Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
CreateAccountGui.showTipsPopup(false);
var shouldJumpAScreen:Boolean = this._isEmailSameAsUserName;
var canContinue:Boolean = this.nextBtnHandler();
if(shouldJumpAScreen)
{
super.parentWizard.next();
}
return canContinue;
}
public function leaveToBoth() : void
{
}
public function leaveToPrev() : Boolean
{
CreateAccountGui.vo3Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
this._numTimesBadUsername = 0;
CreateAccountGui.showNewChrPopup();
CreateAccountGui.showTipsPopup(false);
this._nextBtn.visible = true;
return true;
}
public function updateScreenAssets(isCurrentScreen:Boolean = false) : void
{
var nsfn:int = 0;
var nameSugClip:GuiSoundBtnSubMenu = null;
this._playerTagScreen = this._registrationPanel.userNamePanel.userNameContainer.signup_wizard.act_popup;
this._newBdayMonthDpn = new GuiDropdown(this._playerTagScreen.birthday.dropdown_month);
this._newBdayMonthDpn.init(-1.05,this._selectedBdayMonthIndex,this._selectedBdayMonthIndex == -1 ? "-" : null);
this._newBdayDayDpn = new GuiDropdownDay(this._playerTagScreen.birthday.dropdown_day);
this._newBdayDayDpn.init(0.55,this._selectedBdayDayIndex,this._selectedBdayDayIndex == -1 ? "-" : null);
this._newGenderRbg = new GuiRadioButtonGroup(this._playerTagScreen.ageGender.radioGenderBtn);
this._newGenderRbg.selected = this._selectedGender;
this._newPlayerAgeDpn = new GuiDropdown(this._playerTagScreen.ageGender.dropdown_age);
this._newPlayerAgeDpn.init(0.55,this._selectedBdayAgeIndex,this._selectedBdayAgeIndex == -1 ? "-" : null);
this._nameSuggestionsFrame = this._playerTagScreen.NamePopup;
this._newUsernameTxt = this._playerTagScreen.username.pTag_txt;
this._newUsernameTxt.text = Boolean(this._lastCheckedPlayerTag) ? this._lastCheckedPlayerTag : "";
this._newUsernameBar = this._playerTagScreen.username.textBar1;
this._newPasswordTxt = this._playerTagScreen.password.pswd_txt;
this._newPasswordTxt.text = this._passwordText;
this._newPasswordBar = this._playerTagScreen.password.textBar2;
this._activeSelBar1 = this._playerTagScreen.act_bar_sel1;
this._activeSelBar2 = this._playerTagScreen.act_bar_sel2;
this._activeSelBar3 = this._playerTagScreen.username.act_bar_sel3;
this._activeSelBar4 = this._playerTagScreen.password.act_bar_sel4;
this._tipsNeedTxt = this._playerTagScreen.tips_help_txt;
this._privacyPolicyTxt = this._playerTagScreen.pp_txt;
this._voBtn = this._playerTagScreen.vo_Btn;
this._backBtn = this._creation.accountCreation.back_btn;
this._backBtn.gotoAndStop(1);
this._nextBtn = this._creation.accountCreation.next_btn;
this._nextBtn.gotoAndStop(1);
this._genderAgeSts = this._playerTagScreen.ageGender.genderAge_status;
this._userNameSts = this._playerTagScreen.username.username_status;
this._passWordSts = this._playerTagScreen.password.pswd_status;
this._nameTipPopup = this._playerTagScreen.nameTipPopup;
this._passwordTipPopup = this._playerTagScreen.passwordTipPopup;
this._playerTagScreen.username.changeBtn.visible = false;
this._playerTagScreen.ageGender.visible = true;
this._playerTagScreen.username.visible = true;
this._playerTagScreen.password.visible = true;
GuiStatusIcon.setVisBasedOnTrackers(this._genderAgeSts,this._genderAgeTracking);
GuiStatusIcon.setVisBasedOnTrackers(this._userNameSts,this._userNameTracking);
GuiStatusIcon.setVisBasedOnTrackers(this._passWordSts,this._passWordTracking);
this._nameTipPopup.visible = false;
this._passwordTipPopup.visible = false;
this._validationPending = false;
this._continueClicked = false;
this._nameSuggestionsFrame.visible = false;
this._activeSelBar1.visible = false;
this._activeSelBar2.visible = false;
this._activeSelBar3.visible = false;
this._activeSelBar4.visible = false;
if(isCurrentScreen)
{
this._newUsernameTxt.restrict = "A-Za-z0-9";
this._newUsernameTxt.maxChars = 20;
this._newPasswordTxt.maxChars = 32;
this._nameSuggestionsFrame["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.nameSugCloseBtnMouseDownHandler,false,0,true);
this._nameSugTxts = [];
for(nsfn = 0; nsfn < NUM_SUGGESTED_NAMES; nsfn++)
{
nameSugClip = this._nameSuggestionsFrame["name" + (nsfn + 1)];
this._nameSugTxts[nsfn] = nameSugClip["pTag_txt"];
TextField(this._nameSugTxts[nsfn]).text = "ysername" + nsfn;
nameSugClip.addEventListener(MouseEvent.CLICK,this.nameSugClickHandler,false,0,true);
}
this._newBdayMonthDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler,false,0,true);
this._newBdayDayDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar1FocusHandler,false,0,true);
this._newBdayMonthDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler,false,0,true);
this._newBdayDayDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar1FocusHandler,false,0,true);
this._newGenderRbg.currRadioButton.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler,false,0,true);
this._newPlayerAgeDpn.currDropDown.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar2FocusHandler,false,0,true);
this._newPlayerAgeDpn.currDropDown.addEventListener(FocusEvent.FOCUS_IN,this.selBar2FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(Event.CHANGE,this.userNameTxtChangeHandler,false,0,true);
this._newUsernameTxt.addEventListener(MouseEvent.MOUSE_DOWN,this.selBar3FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(KeyboardEvent.KEY_DOWN,this.selBar3FocusHandler,false,0,true);
this._newUsernameTxt.addEventListener(FocusEvent.FOCUS_IN,this.selBar3FocusHandler,false,0,true);
this._newPasswordTxt.addEventListener(Event.CHANGE,this.passWordTxtChangeHandler,false,0,true);
this._newPasswordTxt.addEventListener(FocusEvent.FOCUS_IN,this.selBar4FocusHandler,false,0,true);
this._tipsNeedTxt.addEventListener(TextEvent.LINK,this.tipsNeedTxtClickHandler,false,0,true);
this._voBtn.addEventListener(MouseEvent.CLICK,this.voBtnClickHandler,false,0,true);
if(Boolean(CreateAccountGui.vo3Sound.sc))
{
this._voBtn.play();
}
else
{
this._voBtn.stop();
}
this.selBar1FocusHandler(null);
this._nextBtn.enabled = false;
if(Boolean(this._userNameSts["_check"].visible) && Boolean(this._passWordSts["_check"].visible))
{
this._nextBtn.visible = true;
}
else
{
this._nextBtn.visible = false;
}
}
}
public function stopVOButton(e:Event) : void
{
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
public function enableNext() : void
{
this._nextBtn.enabled = true;
}
public function userNameValidCallback(validStatus:int, data:Array, returnType:int) : void
{
var i:int = 0;
var suggestedName:Array = null;
this._validationPending = false;
this._userNameSts.visible = true;
if(validStatus == 1)
{
GuiStatusIcon.showCheck(this._userNameSts,this._userNameTracking);
if(Boolean(this._passWordSts["_check"].visible))
{
this._nextBtn.visible = true;
}
this._newUsernameBar.visible = true;
this._nameSuggestionsFrame.visible = false;
if(this._continueClicked || this._isEmailSameAsUserName)
{
if(this.nextBtnHandler())
{
if(super.parentWizard != null)
{
super.parentWizard.next();
}
}
}
}
else
{
if(validStatus == CreateAccountGui.MSG_ID_USERNAME_UNAVAILABLE)
{
if(returnType != CreateAccountXtCommManager.LOGINAVAILABLE_TYPE_SUGGESTIONS)
{
SBTracker.trackPageview("/login/usernameUnavailable/#" + this._numTimesBadUsername,0,SBTracker.TYPE_EVENT);
++this._numTimesBadUsername;
}
suggestedName = [];
for(i = 3; i < data.length; i++)
{
if(data[i] != null && data[i] != "")
{
suggestedName.push(data[i]);
}
}
if(suggestedName.length != 0)
{
this._nameSuggestionsFrame.gotoAndStop(suggestedName.length);
for(i = 0; i < suggestedName.length; i++)
{
TextField(this._nameSugTxts[i]).text = suggestedName[i];
}
this._nameSuggestionsFrame.visible = true;
}
else
{
this._nameSuggestionsFrame.visible = false;
}
this._newBdayMonthDpn.closeDropdownSilent();
this._newBdayDayDpn.closeDropdownSilent();
this._newPlayerAgeDpn.closeDropdownSilent();
}
GuiStatusIcon.showX(this._userNameSts,this._userNameTracking);
this._nextBtn.visible = false;
if(this._newUsernameTxt.text == "")
{
this._userNameSts.visible = this._userNameTracking.xTracking = this._userNameTracking.waitTracking = this._userNameTracking.checkTracking = false;
this._newUsernameBar.visible = true;
}
else
{
this._newUsernameBar.visible = false;
}
}
this._continueClicked = false;
}
public function passWordValidCallback(valid:Boolean) : void
{
this._passWordSts.visible = true;
if(valid)
{
GuiStatusIcon.showCheck(this._passWordSts,this._passWordTracking);
this._newPasswordBar.visible = true;
if(Boolean(this._userNameSts["_check"].visible))
{
this._nextBtn.visible = true;
}
}
else
{
GuiStatusIcon.showX(this._passWordSts,this._passWordTracking);
this._nextBtn.visible = false;
if(this._newPasswordTxt.text.length < CreateAccountGui.MIN_PASSWORD_LENGTH)
{
this._passWordSts.visible = this._passWordTracking.xTracking = this._passWordTracking.waitTracking = this._passWordTracking.checkTracking = false;
this._newPasswordBar.visible = true;
}
else
{
this._newPasswordBar.visible = false;
}
}
}
private function markEmptyAsError() : void
{
if(this._newUsernameTxt.text == "")
{
GuiStatusIcon.showX(this._userNameSts,this._userNameTracking);
this._userNameSts.visible = true;
this._newUsernameBar.visible = false;
}
if(this._newPasswordTxt.text.length < CreateAccountGui.MIN_PASSWORD_LENGTH)
{
if(this._newUsernameTxt.text != "")
{
CreateAccountGui.showNewPasswordBadMsg();
}
GuiStatusIcon.showX(this._passWordSts,this._passWordTracking);
this._passWordSts.visible = true;
this._newPasswordBar.visible = false;
}
}
private function checkUserName() : void
{
if(this._creation.validatedUserName != this._newUsernameTxt.text)
{
if(Boolean(this._creation.validatedUserName))
{
this._creation.invalidateUserName();
}
if(this._newUsernameTxt.text == "")
{
this._userNameSts.visible = this._userNameTracking.xTracking = this._userNameTracking.waitTracking = this._userNameTracking.checkTracking = false;
CreateAccountGui.hideNotifyPopup();
}
else if(this._newUsernameTxt.text != this._lastCheckedPlayerTag)
{
if(this._validationPending)
{
if(!this._userNameKeyUpDelayTimer.running)
{
this._creation.invalidatePending();
}
this._userNameKeyUpDelayTimer.reset();
}
this._validationPending = true;
this._lastCheckedPlayerTag = this._newUsernameTxt.text;
this._userNameSts.visible = true;
GuiStatusIcon.showWait(this._userNameSts,this._userNameTracking);
this._userNameKeyUpDelayTimer.start();
}
}
}
private function checkPassWord() : void
{
this._passWordSts.visible = true;
GuiStatusIcon.showX(this._passWordSts,this._passWordTracking);
if(this._newPasswordTxt.text.length >= CreateAccountGui.MIN_PASSWORD_LENGTH)
{
this._passwordText = this._newPasswordTxt.text;
this._creation.validatePassWord(this._newPasswordTxt.text,this._newUsernameTxt.text,this.passWordValidCallback);
}
else
{
if(this._newPasswordTxt.text.length == 0)
{
this._passWordSts.visible = this._passWordTracking.xTracking = this._passWordTracking.waitTracking = this._passWordTracking.checkTracking = false;
}
this._passwordText = "";
this._nextBtn.visible = false;
this._newPasswordBar.visible = true;
this._creation.invalidatePassWord();
}
}
private function userNameTxtChangeHandler(e:Event) : void
{
this.checkUserName();
this.checkPassWord();
CreateAccountGui.hideNotifyPopup();
}
private function userNameTxtChangeDelayTimerHandler(t:TimerEvent) : void
{
var newUsernameText:String = this._newUsernameTxt.text;
this._newUsernameTxt.text = newUsernameText.substr(0,1) + newUsernameText.substr(1).toLowerCase();
var splitEmail:Array = CreateAccountGui.currEmailAddress().split("@");
if(splitEmail.length > 1)
{
if(splitEmail[0].toLowerCase() != this._newUsernameTxt.text.toLowerCase())
{
this._creation.validateUserName(this._newUsernameTxt.text,this._newPasswordTxt.text,0,0,0,this.userNameValidCallback);
}
else
{
CreateAccountGui.showEmailCannotMatchUserName();
this._validationPending = false;
GuiStatusIcon.showX(this._userNameSts,this._userNameTracking);
}
}
else
{
this._creation.validateUserName(this._newUsernameTxt.text,this._newPasswordTxt.text,0,0,0,this.userNameValidCallback);
}
this._userNameKeyUpDelayTimer.reset();
}
private function nameSugClickHandler(m:MouseEvent) : void
{
this._newUsernameTxt.text = m.currentTarget["pTag_txt"].text;
this.userNameTxtChangeHandler(null);
this._nameSuggestionsFrame.visible = false;
}
private function nameSugCloseBtnMouseDownHandler(m:MouseEvent) : void
{
this._nameSuggestionsFrame.visible = false;
}
private function passWordTxtChangeHandler(e:Event) : void
{
this._lastCheckedPlayerTag = null;
this.checkPassWord();
this.checkUserName();
}
private function selBar1FocusHandler(e:Event) : void
{
var d:Date = null;
if(!this._activeSelBar1.visible)
{
this._activeSelBar1.visible = true;
this._activeSelBar2.visible = false;
this._activeSelBar3.visible = false;
this._activeSelBar4.visible = false;
this._nameSuggestionsFrame.visible = false;
this._nameTipPopup.visible = false;
this._passwordTipPopup.visible = false;
this._newPlayerAgeDpn.closeDropdownSilent();
}
if(Boolean(e))
{
this._selectedBdayMonthIndex = this._newBdayMonthDpn.selectedIdx;
this._selectedBdayDayIndex = this._newBdayDayDpn.selectedIdx;
if(this._selectedBdayMonthIndex != -1 && e.currentTarget == this._playerTagScreen.birthday.dropdown_month)
{
d = new Date(2013,this._selectedBdayMonthIndex + 1,0);
this._newBdayDayDpn.updateDaysShown(d.getDate());
}
}
}
private function selBar2FocusHandler(e:Event) : void
{
if(!this._activeSelBar2.visible)
{
this._activeSelBar1.visible = false;
this._activeSelBar2.visible = true;
this._activeSelBar3.visible = false;
this._activeSelBar4.visible = false;
this._nameSuggestionsFrame.visible = false;
this._nameTipPopup.visible = false;
this._passwordTipPopup.visible = false;
this._newBdayMonthDpn.closeDropdownSilent();
this._newBdayDayDpn.closeDropdownSilent();
}
if(Boolean(e))
{
this._selectedGender = this._newGenderRbg.selected;
this._selectedBdayAgeIndex = this._newPlayerAgeDpn.selectedIdx;
}
}
private function selBar3FocusHandler(e:Event) : void
{
if(!this._activeSelBar3.visible)
{
this._activeSelBar1.visible = false;
this._activeSelBar2.visible = false;
this._activeSelBar3.visible = true;
this._activeSelBar4.visible = false;
this._nameTipPopup.visible = true;
this._passwordTipPopup.visible = false;
this._nameSuggestionsFrame.visible = false;
this._newPlayerAgeDpn.closeDropdownSilent();
this._newBdayMonthDpn.closeDropdownSilent();
this._newBdayDayDpn.closeDropdownSilent();
}
CreateAccountGui.hideNotifyPopup();
}
private function selBar4FocusHandler(f:FocusEvent) : void
{
if(!this._activeSelBar4.visible)
{
this._activeSelBar1.visible = false;
this._activeSelBar2.visible = false;
this._activeSelBar3.visible = false;
this._activeSelBar4.visible = true;
this._nameSuggestionsFrame.visible = false;
this._nameTipPopup.visible = false;
this._passwordTipPopup.visible = true;
this._newPlayerAgeDpn.closeDropdownSilent();
this._newBdayMonthDpn.closeDropdownSilent();
this._newBdayDayDpn.closeDropdownSilent();
}
}
private function tipsNeedTxtClickHandler(m:TextEvent) : void
{
m.preventDefault();
CreateAccountGui.showTipsPopup(true);
}
private function voBtnClickHandler(m:MouseEvent) : void
{
if(CreateAccountGui.vo3Sound.isPlaying)
{
CreateAccountGui.vo3Sound.stop();
this._voBtn.stop();
this._voBtn.gotoAndStop(1);
}
else
{
CreateAccountGui.vo3Sound.play();
if(Boolean(CreateAccountGui.vo3Sound.sc))
{
CreateAccountGui.vo3Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true);
this._voBtn.play();
}
}
}
private function nextBtnHandler() : Boolean
{
if(this._validationPending)
{
this._continueClicked = true;
return false;
}
if(Boolean(this._creation.validatedUserName))
{
if(Boolean(this._creation.validatedPassWord))
{
if(this._newPlayerAgeDpn.selectedIdx < 0)
{
CreateAccountGui.showLoginCreateResultMsg(CreateAccountGui.MSG_ID_AGE_BLANK);
return false;
}
if(this._newGenderRbg.selected < 0)
{
CreateAccountGui.showLoginCreateResultMsg(CreateAccountGui.MSG_ID_SEX_BLANK);
return false;
}
if(this._newBdayDayDpn.selectedIdx < 0 || this._newBdayMonthDpn.selectedIdx < 0)
{
CreateAccountGui.showLoginCreateResultMsg(CreateAccountGui.MSG_ID_MONTH_OR_DAY_BLANK);
return false;
}
this._creation.setBirthday(String(this._newBdayMonthDpn.selectedIdx + 1),this._newBdayDayDpn.selectedTxt.text,String(this._newPlayerAgeDpn.selectedIdx));
this._creation.setGender(this._newGenderRbg.selected);
this._numTimesBadUsername = 0;
this._isEmailSameAsUserName = false;
return true;
}
this.passWordTxtChangeHandler(null);
this.markEmptyAsError();
return false;
}
this._continueClicked = true;
this._creation.validateUserName(this._newUsernameTxt.text,this._newPasswordTxt.text,0,0,0,this.userNameValidCallback);
this.markEmptyAsError();
return false;
}
}
}