Advertisement
Guest User

vip

a guest
Aug 28th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.58 KB | None | 0 0
  1. package myDisplay.window.newvip
  2. {
  3. import myDisplay.window.Wnd_Base;
  4. import com.sincetimes.transport.protocol.RceVipGet;
  5. import myDisplay.global.GlobalReference;
  6. import com.sincetimes.transport.Transport;
  7. import com.sincetimes.transport.protocol.RceVipGetReward;
  8. import com.sincetimes.transport.protocol.RseVipGetReward;
  9. import flash.geom.Point;
  10. import myDisplay.myUI.ScrollSet;
  11. import com.sincetimes.transport.protocol.RseVipGet;
  12. import myDisplay.global.GlobalFunction;
  13. import flash.events.Event;
  14. import flash.events.MouseEvent;
  15. import model.GameEvent;
  16. import com.thor.utils.Locales;
  17. import flash.display.MovieClip;
  18. import com.cc.VIP.VIPData;
  19. import com.sincetimes.transport.protocol.VipReward;
  20. import com.sincetimes.transport.protocol.LuckyReward;
  21. import model.bagData.BagCardItemConfig;
  22. import com.thor.utils.EmbedFontUtil;
  23. import com.thor.constants.FontNames;
  24. import myDisplay.WindowManager;
  25. import Tool.platform.PlatformManager;
  26.  
  27. public class Wnd_VipClub extends Wnd_Base
  28. {
  29.  
  30. public function Wnd_VipClub()
  31. {
  32. this._menuItems = new Array();
  33. super();
  34. self = this;
  35. }
  36.  
  37. private static var self:Wnd_VipClub;
  38.  
  39. private static const MAX_CARD_NUM:int = 5;
  40.  
  41. private static function requestVipInfo() : void
  42. {
  43. GLOBAL._mainLoader.startWaiting(true);
  44. var _loc1_:RceVipGet = new RceVipGet();
  45. if(GlobalReference.supportMagicDiamond)
  46. {
  47. _loc1_.isMagicDiamond = GlobalReference.isMagicDiamond;
  48. }
  49. Transport.Send(_loc1_);
  50. }
  51.  
  52. private static function requestVipGetReward() : void
  53. {
  54. GLOBAL._mainLoader.startWaiting(true);
  55. var _loc1_:RceVipGetReward = new RceVipGetReward();
  56. Transport.Send(_loc1_);
  57. }
  58.  
  59. public static function rseVipGetReward_hd(param1:RseVipGetReward) : void
  60. {
  61. GLOBAL._mainLoader.endWaiting();
  62. self.upatePanel(param1);
  63. }
  64.  
  65. private var panel:ZZVipClubPanel;
  66.  
  67. private var _lastListViewPos:Point;
  68.  
  69. private var _scrollSet:ScrollSet;
  70.  
  71. private var _rseVipGet:RseVipGet;
  72.  
  73. private var _thisLevelReward:ZZVipRewardItem;
  74.  
  75. private var _vipExpSlotLen:Number;
  76.  
  77. private var _menuItems:Array;
  78.  
  79. override protected function excuteBeforeOpen() : void
  80. {
  81. this.panel = this.windowMaterial;
  82. this._vipExpSlotLen = this.panel.vipexpslot.vipexpbar.width;
  83. this.panel.vipexpslot.vipexpbar.width = 0;
  84. GlobalFunction.setTextByKey(this.panel.tTitle,"zz_vip_club_title");
  85. GlobalFunction.setTextByKey(this.panel.youvipleveldesc_tf,"zz_vip_youvipleveldesc");
  86. GlobalFunction.setTextByKey(this.panel.charge_tf,"zz_vip_addCredit");
  87. GlobalFunction.setTextByKey(this.panel.vipstorename_tf,"zz_vip_store_title");
  88. this.panel.help_btn.gotoAndStop(1);
  89. GlobalFunction.addEventListener(this,this.panel,Event.REMOVED_FROM_STAGE,this.onRemove);
  90. GlobalFunction.addEventListener(this,this.panel.help_btn,MouseEvent.CLICK,this.onClickHelp);
  91. GlobalFunction.addEventListener(this,GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.onMouseDownState);
  92. GlobalFunction.addEventListener(this,GlobalReference.dispatcher,GameEvent.EVENT_GOT_VIP_INFO,this.onGotVipInfo);
  93. requestVipInfo();
  94. addTargetEvent(GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.hideTip);
  95. }
  96.  
  97. private function hideTip(param1:MouseEvent) : void
  98. {
  99. GLOBAL.RemoveToolTips(false);
  100. }
  101.  
  102. private function onMouseDownState(param1:MouseEvent) : void
  103. {
  104. GLOBAL.RemoveToolTips(false);
  105. }
  106.  
  107. private function onClickHelp(param1:Event) : void
  108. {
  109. var _loc2_:String = Locales.Get("zz_vip_club_helpmsg");
  110. GLOBAL.ShowToolTips(param1.currentTarget as MovieClip,_loc2_);
  111. }
  112.  
  113. private function onRemove(param1:Event) : void
  114. {
  115. GlobalFunction.removeEventListener(this);
  116. self = null;
  117. }
  118.  
  119. private function onGotVipInfo(param1:GameEvent) : void
  120. {
  121. GLOBAL._mainLoader.endWaiting();
  122. var _loc2_:RseVipGet = param1.data as RseVipGet;
  123. if(_loc2_)
  124. {
  125. this.initPanel(_loc2_);
  126. }
  127. }
  128.  
  129. protected function clearGiftGrid(param1:MovieClip) : void
  130. {
  131. if(param1 == null)
  132. {
  133. return;
  134. }
  135. if(param1.card)
  136. {
  137. try
  138. {
  139. param1.cardpos.removeChild(param1.card);
  140. param1.card = null;
  141. param1.reward = null;
  142. GlobalFunction.setText(param1.num_tf,"");
  143. GlobalFunction.setText(param1.name_tf,"");
  144. }
  145. catch(e:Error)
  146. {
  147. }
  148. }
  149. }
  150.  
  151. private function initMenuItem() : void
  152. {
  153. var _loc6_:MovieClip = null;
  154. var _loc9_:VIPData = null;
  155. var _loc12_:VipReward = null;
  156. var _loc13_:LuckyReward = null;
  157. var _loc14_:BagCardItemConfig = null;
  158. if(this._rseVipGet == null || this._rseVipGet.rewards == null || this._rseVipGet.rewards.length == 0)
  159. {
  160. return;
  161. }
  162. GlobalFunction.addEventListener(this,GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.onMouseDown);
  163. this._scrollSet = new ScrollSet();
  164. var _loc1_:ZZVipRewardItem = new ZZVipRewardItem();
  165. var _loc2_:Number = _loc1_.height;
  166. this._scrollSet.Init(this.panel.maskpanel,ScrollSet.BLUE,ScrollSet.VERTICAL);
  167. this._scrollSet.itemHeight = _loc2_;
  168. this._scrollSet.itemMargin = 10;
  169. this._scrollSet.beginAlterItem();
  170. var _loc3_:int = this._rseVipGet.viplevel;
  171. var _loc4_:int = this._rseVipGet.viplevel;
  172. if(_loc4_ == 0)
  173. {
  174. _loc4_ = 1;
  175. }
  176. var _loc5_:* = 0;
  177. var _loc7_:* = "";
  178. var _loc8_:* = "";
  179. var _loc10_:* = 0;
  180. var _loc11_:* = "";
  181. for each(_loc12_ in this._rseVipGet.rewards)
  182. {
  183. _loc7_ = "";
  184. _loc1_ = new ZZVipRewardItem();
  185. GlobalFunction.setTextByKey(_loc1_.weekgift_tf,"zz_vip_weekgift",_loc4_);
  186. if(_loc4_ != _loc3_)
  187. {
  188. _loc1_.get_btn.visible = false;
  189. _loc1_.gettime_tf.visible = false;
  190. }
  191. else
  192. {
  193. this._thisLevelReward = _loc1_;
  194. }
  195. _loc1_.get_tf.visible = false;
  196. _loc1_.gift_mc.gift_btn.vipLevel = _loc4_;
  197. _loc1_.gift_mc.gift_btn.origVipLevel = _loc3_;
  198. EmbedFontUtil.setText(_loc1_.gift_mc.youviplevel_tf,Locales.Get("zz_vip_getreward_warning",{"v1":_loc4_}),FontNames.NORMAL);
  199. GlobalFunction.addEventListener(this,_loc1_.gift_mc.gift_btn,MouseEvent.MOUSE_UP,this.onClickbtn);
  200. if(_loc12_.cards.length > 0)
  201. {
  202. _loc8_ = "";
  203. _loc10_ = 0;
  204. while(_loc10_ < _loc12_.cards.length)
  205. {
  206. _loc13_ = _loc12_.cards[_loc10_];
  207. _loc14_ = BagCardItemConfig.getCardConfigByItemId(_loc13_.cardId);
  208. if(_loc14_)
  209. {
  210. _loc8_ = _loc8_ + (_loc14_.name + "*" + _loc13_.cardNum + "\n");
  211. }
  212. _loc10_++;
  213. }
  214. if(_loc8_.length > 0)
  215. {
  216. _loc7_ = _loc7_ + Locales.Get("zz_VIP_rewardweekly",{"v1":_loc4_});
  217. _loc11_ = "<font color=\"#FFFF00\">" + Locales.Get("zz_vip_getreward_warning",{"v1":_loc4_}) + "</font>\n" + _loc8_;
  218. _loc1_.gift_mc.gift_btn.tipStr = _loc11_;
  219. }
  220. }
  221. _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward2",{"v1":_loc4_});
  222. _loc9_ = VIPData.getVIPDataBylevel(_loc4_);
  223. if(_loc9_)
  224. {
  225. if(_loc9_.feast_add > 0)
  226. {
  227. _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward3",{"v1":_loc9_.feast_add});
  228. }
  229. if(_loc9_.defence_extra_count > 0)
  230. {
  231. _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward4",{"v1":_loc9_.defence_extra_count});
  232. }
  233. _loc8_ = "";
  234. if(_loc9_.capacity_0 > 0)
  235. {
  236. _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_0",{"v1":_loc9_.capacity_0}) + ",");
  237. }
  238. if(_loc9_.capacity_1 > 0)
  239. {
  240. _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_1",{"v1":_loc9_.capacity_1}) + ",");
  241. }
  242. if(_loc9_.capacity_2 > 0)
  243. {
  244. _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_2",{"v1":_loc9_.capacity_2}) + ",");
  245. }
  246. if(_loc8_.length > 0)
  247. {
  248. _loc8_ = _loc8_.slice(0,_loc8_.length - 1);
  249. }
  250. if(_loc8_.length > 0)
  251. {
  252. _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward5",{"v1":_loc8_});
  253. }
  254. if(_loc9_.lianmeng > 0)
  255. {
  256. _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward6_" + _loc9_.lianmeng);
  257. }
  258. }
  259. EmbedFontUtil.setHtmlText(_loc1_.reward_tf,_loc7_,FontNames.NORMAL);
  260. _loc4_++;
  261. this._scrollSet.addItem(_loc1_);
  262. }
  263. this._scrollSet.endAlterItem();
  264. }
  265.  
  266. private function onClickbtn(param1:MouseEvent) : void
  267. {
  268. var _loc2_:int = GlobalFunction.getServerSecond();
  269. if(!(param1.currentTarget.vipLevel == param1.currentTarget.origVipLevel) || this._rseVipGet.nextTime > _loc2_)
  270. {
  271. GLOBAL.ShowToolTips(param1.currentTarget as MovieClip,param1.currentTarget.tipStr,0,0,true,true);
  272. }
  273. else
  274. {
  275. this.onClickGetReward(param1);
  276. }
  277. }
  278.  
  279. private function onMouseDown(param1:MouseEvent) : void
  280. {
  281. this._lastListViewPos = new Point(this._scrollSet.listView.x,this._scrollSet.listView.y);
  282. }
  283.  
  284. private function onClickGetReward(param1:MouseEvent) : void
  285. {
  286. if(Point.distance(this._lastListViewPos,new Point(this._scrollSet.listView.x,this._scrollSet.listView.y)) > 10)
  287. {
  288. return;
  289. }
  290. var _loc2_:int = GlobalFunction.getServerSecond();
  291. if(_loc2_ <= this._rseVipGet.nextTime)
  292. {
  293. return;
  294. }
  295. requestVipGetReward();
  296. }
  297.  
  298. private function initPanel(param1:RseVipGet) : void
  299. {
  300. if(param1.succ != 0)
  301. {
  302. this.showErrMsg(param1.succ);
  303. return;
  304. }
  305. this._rseVipGet = param1;
  306. GlobalFunction.setTextByKey(this.panel.youviplevel_tf,"zz_vip_level",param1.viplevel);
  307. GlobalFunction.setText(this.panel.vipexp_tf,param1.haspayed + "/" + param1.nextLevelNeed);
  308. var _loc2_:Number = this._vipExpSlotLen * param1.haspayed / param1.nextLevelNeed;
  309. if(_loc2_ < 0)
  310. {
  311. _loc2_ = 0;
  312. }
  313. else if(_loc2_ > this._vipExpSlotLen)
  314. {
  315. _loc2_ = this._vipExpSlotLen;
  316. }
  317.  
  318. this.panel.vipexpslot.vipexpbar.width = _loc2_;
  319. if((GlobalReference.supportMagicDiamond) && !(param1.isHasQQMagicLimit == 0) && !param1.isQQMagic)
  320. {
  321. GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_notmagicdiamond");
  322. }
  323. else if(param1.viplevel == 0)
  324. {
  325. GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_notVipDesc",param1.nextLevelNeed - param1.haspayed,1);
  326. }
  327. else if(param1.haspayed != param1.nextLevelNeed)
  328. {
  329. GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_nomalVipDesc",param1.nextLevelNeed - param1.haspayed,param1.viplevel + 1);
  330. }
  331. else
  332. {
  333. GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_topVipDesc");
  334. }
  335.  
  336.  
  337. this.initMenuItem();
  338. GlobalFunction.addEventListener(this,this.panel.charge_btn,MouseEvent.CLICK,this.onClickCharge);
  339. GlobalFunction.addEventListener(this,this.panel.vipstore_btn,MouseEvent.CLICK,this.onClickVipStore);
  340. GlobalFunction.addEventListener(this,this.panel,Event.ENTER_FRAME,this.onEnterFrame);
  341. }
  342.  
  343. private function onClickVipStore(param1:Event) : void
  344. {
  345. if(this._rseVipGet)
  346. {
  347. Wnd_VipStore.rseVipGet = this._rseVipGet;
  348. Wnd_VipStore.parentWnd = this;
  349. WindowManager.getInstance().openWindow(WindowManager.ZZVipStore);
  350. }
  351. }
  352.  
  353. private function onClickCharge(param1:Event) : void
  354. {
  355. PlatformManager.getInstance().showChongzhi();
  356. closeWindow(null);
  357. }
  358.  
  359. private function upatePanel(param1:RseVipGetReward) : void
  360. {
  361. var reward:VipReward = null;
  362. var cardMsg:String = null;
  363. var card:LuckyReward = null;
  364. var msg:String = null;
  365. var errFunc:Function = null;
  366. var rse:RseVipGetReward = param1;
  367. if(rse.succ != 0)
  368. {
  369. this.showErrMsg(rse.succ);
  370. return;
  371. }
  372. if((this._rseVipGet) && (this._thisLevelReward) && !(this._rseVipGet.rewards.length == 0))
  373. {
  374. this._rseVipGet.nextTime = rse.nextTime;
  375. this._thisLevelReward.get_btn.visible = false;
  376. this._thisLevelReward.gettime_tf.visible = false;
  377. reward = this._rseVipGet.rewards[0] as VipReward;
  378. if((reward) && (reward.cards) && !(reward.cards.length == 0))
  379. {
  380. cardMsg = "";
  381. for each(card in reward.cards)
  382. {
  383. cardMsg = cardMsg + (GlobalFunction.getCardNameByID(card.cardId) + "\tx" + card.cardNum + "\n");
  384. }
  385. msg = Locales.Get("zz_vip_rewarddesc",{"v1":cardMsg});
  386. errFunc = function():void
  387. {
  388. POPUPS.Next();
  389. };
  390. POPUPS.DisplayCCbot(Locales.Get("zz_vip_club_title"),msg,Locales.Get("btn_ok"),errFunc,false,false,true,errFunc);
  391. }
  392. }
  393. }
  394.  
  395. private function onEnterFrame(param1:Event) : void
  396. {
  397. var _loc2_:* = 0;
  398. var _loc3_:* = 0;
  399. if(this._rseVipGet == null || this._thisLevelReward == null)
  400. {
  401. return;
  402. }
  403. if(this._rseVipGet.viplevel != 0)
  404. {
  405. _loc2_ = GlobalFunction.getServerSecond();
  406. _loc3_ = this._rseVipGet.nextTime - _loc2_ + 1;
  407. if(_loc3_ < 0)
  408. {
  409. this._thisLevelReward.get_btn.visible = false;
  410. this._thisLevelReward.gettime_tf.visible = false;
  411. EmbedFontUtil.setText(this._thisLevelReward.gift_mc.lefttime_tf,Locales.Get("ui_canGetGift"),FontNames.NORMAL);
  412. }
  413. else
  414. {
  415. this._thisLevelReward.get_btn.visible = false;
  416. this._thisLevelReward.gettime_tf.visible = false;
  417. if(_loc3_ > 3600 * 24)
  418. {
  419. GlobalFunction.setText(this._thisLevelReward.gift_mc.lefttime_tf,GlobalFunction.getDHMByLeftSecond(_loc3_));
  420. }
  421. else
  422. {
  423. GlobalFunction.setText(this._thisLevelReward.gift_mc.lefttime_tf,GlobalFunction.getHMSByLeftSecond(_loc3_));
  424. }
  425. }
  426. }
  427. }
  428.  
  429. public function showErrMsg(param1:int) : void
  430. {
  431. var errType:int = param1;
  432. var errMsg:String = GlobalFunction.getErrMsgByType(errType);
  433. var errFunc:Function = function():void
  434. {
  435. POPUPS.Next();
  436. closeWindow();
  437. };
  438. POPUPS.DisplayCCbot(Locales.Get("zz_vip_club_title"),errMsg,Locales.Get("btn_ok"),errFunc,false,false,true,errFunc);
  439. }
  440.  
  441. override protected function get windowClassName() : Class
  442. {
  443. return ZZVipClubPanel;
  444. }
  445.  
  446. private function get windowMaterial() : ZZVipClubPanel
  447. {
  448. return material as ZZVipClubPanel;
  449. }
  450. }
  451. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement