CAreYouSurePanel.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. function CAreYouSurePanel() {
  2. var _aCbCompleted;
  3. var _aCbOwner;
  4. var _oBg;
  5. var _oMsg;
  6. var _oButYes;
  7. var _oButNo;
  8. var _oContainer;
  9. var _oFade;
  10. var _oThis = this;
  11. this._init = function () {
  12. _aCbCompleted = new Array();
  13. _aCbOwner = new Array();
  14. _oContainer = new createjs.Container();
  15. _oContainer.visible = false;
  16. s_oStage.addChild(_oContainer);
  17. _oFade = new createjs.Shape();
  18. _oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
  19. _oFade.alpha = 0.5;
  20. _oFade.on("click", function () {});
  21. _oContainer.addChild(_oFade);
  22. var oSpriteBg = s_oSpriteLibrary.getSprite('msg_box');
  23. _oBg = createBitmap(oSpriteBg);
  24. _oBg.x = CANVAS_WIDTH/2;
  25. _oBg.y = CANVAS_HEIGHT/2;
  26. _oBg.regX = oSpriteBg.width * 0.5;
  27. _oBg.regY = oSpriteBg.height * 0.5;
  28. _oContainer.addChild(_oBg);
  29. _oMsg = new CTLText(_oContainer,
  30. CANVAS_WIDTH/2-300, (CANVAS_HEIGHT/2)-150, 600, 150,
  31. 70, "center", "#fff", PRIMARY_FONT, 1,
  32. 0, 0,
  33. TEXT_ARE_SURE,
  34. true, true, true,
  35. false );
  36. _oButYes = new CGfxButton(CANVAS_WIDTH / 2 + 150, CANVAS_HEIGHT * 0.5 + 70, s_oSpriteLibrary.getSprite('but_yes'), _oContainer);
  37. _oButYes.addEventListener(ON_MOUSE_UP, this._onButYes, this);
  38. _oButNo = new CGfxButton(CANVAS_WIDTH / 2 - 150, CANVAS_HEIGHT * 0.5 + 70, s_oSpriteLibrary.getSprite('but_no'), _oContainer);
  39. _oButNo.addEventListener(ON_MOUSE_UP, this._onButNo, this);
  40. };
  41. this.addEventListener = function (iEvent, cbCompleted, cbOwner) {
  42. _aCbCompleted[iEvent] = cbCompleted;
  43. _aCbOwner[iEvent] = cbOwner;
  44. };
  45. this.show = function (szMsg) {
  46. _oMsg.refreshText(szMsg);
  47. _oContainer.alpha = 0;
  48. _oContainer.visible = true;
  49. createjs.Tween.get(_oContainer).to({alpha: 1}, 300, createjs.Ease.quartOut).call(function(){s_oMain.stopUpdateNoBlock();});
  50. };
  51. this.hide = function(){
  52. s_oMain.startUpdateNoBlock();
  53. createjs.Tween.get(_oContainer).to({alpha: 0}, 500, createjs.Ease.quartOut).call(function(){_oContainer.visible = false;});
  54. };
  55. this.unload = function () {
  56. _oButNo.unload();
  57. _oButYes.unload();
  58. };
  59. this._onButYes = function () {
  60. _oThis.hide();
  61. if (_aCbCompleted[ON_BUT_YES_DOWN]) {
  62. _aCbCompleted[ON_BUT_YES_DOWN].call(_aCbOwner[ON_BUT_YES_DOWN]);
  63. }
  64. };
  65. this._onButNo = function () {
  66. _oThis.hide();
  67. };
  68. this._init();
  69. }