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; 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; public function GuiChooseAnimal(param1:Object, param2:SBWizard, param3:Boolean) { this._chooseScreen = param3 ? param1.registrationPanel.chooseAnimal : param1.accountCreation.registrationPanel.chooseAnimal; super(this._chooseScreen,param2); this._amlNameTxt = this._chooseScreen.animalNameText; this._itemWindow = this._chooseScreen.itemWindow; this._titleText = this._chooseScreen.titleText; this._isFromWorld = param3; this._wizard = param2; if(param3) { this._backBtn = param1.back_btn; this._nextBtn = param1.next_btn; this._playBtn = param1.play_btn; this._avatarHolder = param1.allAvatars; this._buyBtnGreen = param1.buy_btn_green; this._buyBtnRed = param1.buy_btn_red; this._tag = this._chooseScreen.tag; } else { this._voBtn = this._chooseScreen.vo_btn; this._playBtn = param1.accountCreation.play_btn; this._backBtn = param1.accountCreation.back_btn; this._nextBtn = param1.accountCreation.next_btn; this._avatarHolder = param1.accountCreation.allAvatars; } } public function init() : void { onEnterFromNext = this.enterFromNext; onEnterFromPrev = this.enterFromPrev; onLeaveToPrev = this.leaveToPrev; onLeaveToNext = this.leaveToNext; onClose = this.leaveToPrev; 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(CreateAccountGui.vo1Sound.sc) { CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true); this._voBtn.play(); } } } override public function destroy() : void { if(this._avatarWindows) { this._avatarWindows.destroy(); this._avatarWindows = null; } if(this._scrollBar) { this._scrollBar.destroy(); this._scrollBar = null; } super.destroy(); } public function destroyReloadedItems() : void { if(this._avatarWindows) { this._avatarWindows.destroy(); this._avatarWindows = null; } if(this._scrollBar) { this._scrollBar.destroy(); this._scrollBar = null; } } public function reload(param1:Boolean, param2:Boolean, param3:int = -1, param4:Boolean = false, param5:int = 0, param6:int = -1) : void { 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; AvatarUtility.creationAssets.creationWiz.step = 1; this._currencyType = param5; this.setupIcons(true); if(param5 == Item.GEM_CURRENCY) { this._myCurrencyCount = gMainFrame.clientInfo.gemCount; } else if(param5 == Item.DIAMOND_CURRENCY) { this._myCurrencyCount = gMainFrame.clientInfo.diamondCount; } this._isChoosingOceanAvatars = param1; this._isChoosingFirstNonMember = param2; this._nextBtn.visible = true; this._buyBtnGreen.visible = false; this._buyBtnRed.visible = false; this._tag.visible = false; this._backBtn.visible = false; this._isCreatingWithoutChoosing = param4; if(Boolean(this._currAvatar) && Boolean(this._currBG)) { this.enterFromPrev(); } if(this._isChoosingOceanAvatars) { this._currAvatarIconIds = this._oceanOnlyIconIds; this._currAvatarTypes = this._oceanOnlyTypes; } else { this._currAvatarIconIds = this._usableAvatarIconIds; this._currAvatarTypes = this._usableAvatarTypes; } this.pickRandomAvatar(param3,param6); if(param4) { this._wizard.next(); return; } this.createAvatarWindows(); } public function enterFromNext() : void { MovieClip(this._chooseScreen.parent).gotoAndPlay("backChooseAnAnimal"); this._currAvatar.gotoAndPlay("backChooseAnAnimal"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndPlay("backChooseAnAnimal"); if(this._isFromWorld) { this._buyBtnGreen.visible = false; this._buyBtnRed.visible = false; this._nextBtn.visible = true; } else if(CreateAccountGui.vo1Sound) { CreateAccountGui.vo1Sound.play(); if(CreateAccountGui.vo1Sound.sc) { CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true); this._voBtn.play(); } } this.enterFromBoth(); } public function enterFromPrev() : void { MovieClip(this._chooseScreen.parent).gotoAndStop("intro"); this._currAvatar.gotoAndStop("intro"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndStop("intro"); this.enterFromBoth(); } public function enterFromBoth() : void { if(this._isFromWorld) { SBTracker.trackPageview("/game/play/popup/avatarCreation/ChooseAnimal"); } else { CreateAccountGui.trackUserCreateAccountPageChange("ChooseAnimal"); } } public function leaveToNext() : Boolean { var _loc1_:Object = null; if(this._nextBtn.isGray) { return false; } if(!this._isFromWorld) { if(CreateAccountGui.vo1Sound) { CreateAccountGui.vo1Sound.stop(); } this._voBtn.stop(); this._voBtn.gotoAndStop(1); } if(!gMainFrame.userInfo.isMember) { _loc1_ = AvatarUtility.avatarDefInfo[AvatarUtility.findAvDefIndexByType(this._currType)]; if(_loc1_.isMemberOnly) { if(this._isCreatingWithoutChoosing && MovieClip(this._chooseScreen.parent).currentFrameLabel != "chooseAName") { MovieClip(this._chooseScreen.parent).gotoAndStop("chooseAName"); this._currAvatar.gotoAndStop("chooseAName"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndStop("chooseAName"); } else { UpsellManager.displayPopup(UpsellManager.ANIMALS,"createMembersOnlyAvatar"); } } else if(AvatarUtility.numNonMemberAvatars() >= 2 && !this._isChoosingFirstNonMember) { UpsellManager.displayPopup(UpsellManager.ANIMAL_SLOTS,"buyThirdAvatar"); } else { if(!(this._isChoosingFirstNonMember && _loc1_.enviroFlag == 2)) { if(this._isCreatingWithoutChoosing) { MovieClip(this._chooseScreen.parent).gotoAndStop("chooseAName"); this._currAvatar.gotoAndStop("chooseAName"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndStop("chooseAName"); } else { MovieClip(this._chooseScreen.parent).gotoAndPlay("playChooseAName"); this._currAvatar.gotoAndPlay("playChooseAName"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndPlay("playChooseAName"); } return true; } new SBOkPopup(this._chooseScreen.parent.parent.parent.parent,"You must create at least one land animal."); } return false; } if(this._isCreatingWithoutChoosing) { MovieClip(this._chooseScreen.parent).gotoAndStop("chooseAName"); this._currAvatar.gotoAndStop("chooseAName"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndStop("chooseAName"); } else { MovieClip(this._chooseScreen.parent).gotoAndPlay("playChooseAName"); this._currAvatar.gotoAndPlay("playChooseAName"); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndPlay("playChooseAName"); } return true; } public function leaveToPrev() : Boolean { if(!this._isFromWorld) { if(CreateAccountGui.vo1Sound) { CreateAccountGui.vo1Sound.stop(); } this._voBtn.stop(); this._voBtn.gotoAndStop(1); } this._newAvatarFacilitator.nameTypeScreenDone(); return true; } public function leaveToBoth() : Boolean { return true; } 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 this._avatarNamesByType[this._currType]; } private function setupIcons(param1:Boolean = false) : void { var _loc3_:int = 0; var _loc4_:Object = null; var _loc2_:Array = AvatarUtility.creationAvatars; this._usableAvatarIconIds = []; this._usableAvatarTypes = []; this._oceanOnlyIconIds = []; this._oceanOnlyTypes = []; var _loc5_:int = 0; for(; _loc5_ < _loc2_.length; _loc5_++) { try { if(Boolean(AvatarUtility.avatarDefInfo && AvatarUtility.avatarDefInfo.length > 0) && Boolean(_loc5_ < AvatarUtility.avatarDefInfo.length) && Boolean(AvatarUtility.avatarDefInfo[_loc5_])) { _loc3_ = int(gMainFrame.userInfo.getAvatarDefByAvType(_loc2_[_loc5_].avTypeId).iconMediaId); _loc4_ = AvatarUtility.avatarDefInfo[_loc5_]; if((this._avtViewsFlag & 1 << AvatarUtility.avatarTypes[_loc5_] - 1) != 0) { if(!this._isFromWorld && (AvatarUtility.isEndangered(_loc4_.availability) || AvatarUtility.isExtinct(_loc4_.availability))) { continue; } this._usableAvatarIconIds.push(_loc3_); this._usableAvatarTypes.push(_loc2_[_loc5_].avTypeId); } if(Utility.isOcean(AvatarUtility.avatarDefInfo[_loc5_].enviroFlag)) { this._oceanOnlyIconIds.push(_loc3_); this._oceanOnlyTypes.push(_loc2_[_loc5_].avTypeId); } LocalizationXtCommManager.sendTranslateStringRequest(gMainFrame.userInfo.getAvatarDefByAvType(_loc2_[_loc5_].avTypeId).titleStrRef,LocalizationXtCommManager.LANG_ENG,this.onAvtNames,_loc2_[_loc5_].avTypeId); } } catch(e:Error) { } } this._currAvatarIconIds = this._usableAvatarIconIds; this._currAvatarTypes = this._usableAvatarTypes; if(!this._isFromWorld && !param1) { this.pickRandomAvatar(); this.createAvatarWindows(); } } private function pickRandomAvatar(param1:int = -1, param2:int = -1) : void { var _loc3_:int = 0; if(param1 == -1) { this._currIndex = Math.floor(Math.random() * (this._currAvatarTypes.length - 1 - 0 + 1)) + 0; param1 = int(this._currAvatarTypes[this._currIndex]); } else { _loc3_ = 0; while(_loc3_ < this._currAvatarTypes.length) { if(this._currAvatarTypes[_loc3_] == param1) { this._currIndex = _loc3_; break; } _loc3_++; } } this._diamondCost = param2; this._currType = param1; this.setupCurrAvatar(); } private function onAvtNames(param1:int, param2:String, param3:Object) : void { this._avatarNamesByType[param3] = param2; if(Boolean(this._currType) && param3 == this._currType) { this._amlNameTxt.text = this._avatarNamesByType[this._currType]; } } private function createAvatarWindows() : void { this._itemsLoadingSpiral.visible = true; if(this._avatarWindows) { this._avatarWindows.destroy(); this._avatarWindows = null; } if(this._scrollBar) { this._scrollBar.destroy(); this._scrollBar = 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 = new SBScrollbar(); this._scrollBar.init(this._avatarWindows,this._avatarWindows.width,this._avatarWindows.boxHeight * 3 + 2 * 3,10,"scrollbar2",this._avatarWindows.boxHeight + 2,0,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(param1:MouseEvent) : void { param1.stopPropagation(); if(this._currIndex != param1.currentTarget.index) { MovieClip(this._avatarWindows.bg.getChildAt(this._currIndex)).deselect(); this._currIndex = param1.currentTarget.index; this._currType = this._currAvatarTypes[param1.currentTarget.index]; if(param1.currentTarget.currWindow.currentFrameLabel != "down") { param1.currentTarget.currWindow.gotoAndStop("down"); } this.setupCurrAvatar(); } } private function setupCurrAvatar() : void { var _loc2_:Array = null; var _loc4_:Object = null; var _loc1_:Array = this._avatarHolder.currentLabels; var _loc3_:int = 0; while(_loc3_ < _loc1_.length) { _loc2_ = _loc1_[_loc3_].name.split("_"); if(_loc2_[1] == this._currType) { this._currBG = _loc2_[0]; this._avatarHolder.gotoAndStop(this._currBG + "_" + this._currType); this._currAvatar = this._avatarHolder["avatar" + this._currType]; break; } _loc3_++; } if(this._currAvatar) { if(this._avatarNamesByType[this._currType]) { this._amlNameTxt.text = this._avatarNamesByType[this._currType]; } this._currAvatar.gotoAndPlay("intro"); _loc4_ = AvatarUtility.avatarDefInfo[AvatarUtility.findAvatarIndexByType(this._currType)]; if(this._isFromWorld) { this._currCost = this._diamondCost == -1 ? int(_loc4_.cost) : this._diamondCost; if(!this._isChoosingFirstNonMember) { this._tag.txt.text = String(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; this._tag.txt.text = "Free"; } if(!this._tag.visible) { this._tag.visible = true; } } if(AvatarUtility.isEndangered(_loc4_.availability)) { if(this._currType == 13 || this._currType == 16 || this._currType == 26) { MovieClip(this._chooseScreen.parent.parent).endangeredSign.txt.text = "Traveling!"; } else { MovieClip(this._chooseScreen.parent.parent).endangeredSign.txt.text = "Exploring!"; } MovieClip(this._chooseScreen.parent.parent).endangeredSign.visible = true; } else { MovieClip(this._chooseScreen.parent.parent).endangeredSign.visible = false; } if(AvatarUtility.isEndangered(_loc4_.availability) || AvatarUtility.isExtinct(_loc4_.availability)) { this._nextBtn.activateGrayState(true); if(this._isFromWorld) { this._tag.visible = false; } } else { this._nextBtn.activateGrayState(false); if(this._isFromWorld) { this._tag.visible = true; } } } if(this._currBG) { if(MovieClip(this._chooseScreen.parent.parent).bg.currentFrameLabel != this._currBG) { MovieClip(this._chooseScreen.parent.parent).bg.gotoAndStop(this._currBG); MovieClip(this._chooseScreen.parent.parent).bg[this._currBG + "Bg"].gotoAndPlay("intro"); } } } private function winMouseOver(param1:MouseEvent) : void { if(param1) { param1.stopPropagation(); } if(param1.currentTarget.currWindow.currentFrameLabel == "down") { param1.currentTarget.currWindow.gotoAndStop("downMouse"); } else if(param1.currentTarget.currWindow.currentFrameLabel != "downMouse") { param1.currentTarget.currWindow.gotoAndStop("over"); } AJAudio.playSubMenuBtnRollover(); } private function winMouseOut(param1:MouseEvent) : void { if(param1) { param1.stopPropagation(); } if(param1.currentTarget.currWindow.currentFrameLabel == "downMouse") { param1.currentTarget.currWindow.gotoAndStop("down"); } else if(param1.currentTarget.currWindow.currentFrameLabel != "down") { param1.currentTarget.currWindow.gotoAndStop("up"); } } private function stopVOButton(param1:Event) : void { if(CreateAccountGui) { CreateAccountGui.vo1Sound.stop(); } this._voBtn.stop(); this._voBtn.gotoAndStop(1); } private function voBtnClickHandler(param1:MouseEvent) : void { param1.stopPropagation(); if(CreateAccountGui.vo1Sound.isPlaying) { CreateAccountGui.vo1Sound.stop(); this._voBtn.stop(); this._voBtn.gotoAndStop(1); } else { CreateAccountGui.vo1Sound.play(); if(CreateAccountGui.vo1Sound.sc) { CreateAccountGui.vo1Sound.sc.addEventListener(Event.SOUND_COMPLETE,this.stopVOButton,false,0,true); this._voBtn.play(); } } } } }