home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / fwg_knight.swf / scripts / __Packages / PopUp.as < prev    next >
Encoding:
Text File  |  2008-08-28  |  7.4 KB  |  186 lines

  1. class PopUp extends MovieClip
  2. {
  3.    var sFrame;
  4.    var aSt;
  5.    var nWidth;
  6.    var bt_Y;
  7.    var bt_N;
  8.    var bt_X;
  9.    var tT_0;
  10.    var nHeight;
  11.    var tT_1;
  12.    var tT_2;
  13.    var mBar;
  14.    static var nBorder = 4;
  15.    static var nOffset_x = 40;
  16.    static var nWidth_s = 340;
  17.    static var nHeight_s = 180;
  18.    var bScreen = true;
  19.    function PopUp()
  20.    {
  21.       super();
  22.    }
  23.    function init()
  24.    {
  25.       if(this._y == 0)
  26.       {
  27.          this._x = Global.WIDTH / 2;
  28.          this._y = Global.HEIGHT / 2;
  29.       }
  30.       if(this.bScreen)
  31.       {
  32.          Common.enabledFor(true,this,_root,-16384);
  33.       }
  34.       else
  35.       {
  36.          Common.enabledFor(true,this,this,-16384);
  37.       }
  38.       switch(this.sFrame)
  39.       {
  40.          case "y_n":
  41.             this.attachMovie("Btn","bt_X",10,{sTxt:"X",autoSize:"right"});
  42.             this.attachMovie("Btn","bt_Y",9,{sTxt:(this.aSt[1] != undefined ? this.aSt[1] : "YES"),autoSize:"right"});
  43.             ┬º┬ºpush("sTxt");
  44.             ┬º┬ºpush(this.aSt[2]);
  45.             ┬º┬ºpush(undefined);
  46.             break;
  47.          case "ok":
  48.             this.attachMovie("Btn","bt_X",10,{sTxt:"X",autoSize:"right"});
  49.             this.attachMovie("Btn","bt_Y",9,{sTxt:(this.aSt[1] != undefined ? this.aSt[1] : "OK"),autoSize:"center"});
  50.             this.attachMovie("Txt","tT_0",7,{sTxt:(this.aSt[0] != undefined ? this.aSt[0] : "TXT"),_obFormat:{align:"center"},obCustom:{bCustom:true,multiline:true,wordWrap:true}});
  51.             addr203:
  52.             this.gotoAndStop(2);
  53.             break;
  54.          case "submit":
  55.             this.attachMovie("Btn","bt_X",10,{sTxt:"X",autoSize:"right"});
  56.             this.attachMovie("Btn","bt_Y",9,{sTxt:"SUBMIT",autoSize:"center"});
  57.             this.attachMovie("Txt","tT_0",8,{sTxt:"NAME :"});
  58.             this.attachMovie("Txt","tT_1",7,{sTxt:"SCORE : " + (this.aSt[1] != undefined ? this.aSt[1] : 0)});
  59.             this.attachMovie("Txt","tT_2",6,{sTxt:(this.aSt[0] != undefined ? this.aSt[0] : "YOUR NAME"),obCustom:{bCustom:true,type:"input",selectable:true,maxChars:9,restrict:"^ ",border:true,borderColor:0}});
  60.             ┬º┬ºgoto(addr203);
  61.          case "message":
  62.             this.attachMovie("Txt","tT_0",10,{sTxt:(this.aSt[0] != undefined ? this.aSt[0] : "TXT"),_obFormat:{align:"center"}});
  63.             ┬º┬ºgoto(addr203);
  64.          default:
  65.             ┬º┬ºgoto(addr203);
  66.       }
  67.    }
  68.    function inFrame()
  69.    {
  70.       switch(this.sFrame)
  71.       {
  72.          case "y_n":
  73.             this.nWidth = int(Math.max(PopUp.nWidth_s,this.bt_Y._width + this.bt_N._width + PopUp.nOffset_x * 3));
  74.             this.bt_X._x = int(this.nWidth / 2 - PopUp.nBorder - Btn.nBorder);
  75.             this.bt_Y._x = int(- PopUp.nOffset_x);
  76.             this.bt_N._x = int(PopUp.nOffset_x);
  77.             this.tT_0._x = 0;
  78.             this.tT_0.tTxt._width = this.nWidth - PopUp.nOffset_x;
  79.             this.tT_0.replace();
  80.             this.nHeight = int(Math.max(PopUp.nHeight_s,this.tT_0.tTxt.textHeight + PopUp.nOffset_x * 3));
  81.             this.bt_X._y = int((- this.nHeight) / 2 + PopUp.nBorder);
  82.             this.bt_N._y = _loc0_ = int(this.nHeight / 2 - PopUp.nOffset_x);
  83.             this.bt_Y._y = _loc0_;
  84.             this.tT_0._y = - int(PopUp.nOffset_x / 2 + this.tT_0.tTxt.textHeight / 2);
  85.             this.bt_Y.release = function()
  86.             {
  87.                if(this._parent.rtFun(true))
  88.                {
  89.                   this._parent.remove();
  90.                }
  91.             };
  92.             this.bt_N.release = function()
  93.             {
  94.                if(this._parent.rtFun(false))
  95.                {
  96.                   this._parent.remove();
  97.                }
  98.             };
  99.             break;
  100.          case "ok":
  101.             this.nWidth = PopUp.nWidth_s;
  102.             this.bt_X._x = int(this.nWidth / 2 - PopUp.nBorder - Btn.nBorder);
  103.             this.bt_Y._x = 0;
  104.             this.tT_0._x = 0;
  105.             this.tT_0.tTxt._width = this.nWidth - PopUp.nOffset_x;
  106.             this.tT_0.replace();
  107.             this.nHeight = int(Math.max(PopUp.nHeight_s,this.tT_0.tTxt.textHeight + PopUp.nOffset_x * 3));
  108.             this.bt_X._y = int((- this.nHeight) / 2 + PopUp.nBorder);
  109.             this.bt_Y._y = int(this.nHeight / 2 - PopUp.nOffset_x);
  110.             this.tT_0._y = - int(PopUp.nOffset_x / 2 + this.tT_0.tTxt.textHeight / 2);
  111.             this.bt_Y.release = function()
  112.             {
  113.                if(this._parent.rtFun(true))
  114.                {
  115.                   this._parent.remove();
  116.                }
  117.             };
  118.             break;
  119.          case "submit":
  120.             this.nWidth = int(Math.max(PopUp.nWidth_s,this.tT_1.tTxt.textWidth + this.tT_2.tTxt.textWidth + PopUp.nOffset_x * 2));
  121.             this.bt_X._x = int(this.nWidth / 2 - PopUp.nBorder - Btn.nBorder);
  122.             this.tT_1._x = _loc0_ = int((- this.nWidth) / 2 + PopUp.nOffset_x);
  123.             this.tT_0._x = _loc0_;
  124.             this.tT_2._x = this.tT_0._x + this.tT_0.tTxt.textWidth + 15;
  125.             this.nHeight = int(PopUp.nOffset_x * 5);
  126.             this.bt_X._y = int((- this.nHeight) / 2 + PopUp.nBorder);
  127.             this.bt_Y._y = int((- this.nHeight) / 2 + PopUp.nOffset_x * 4);
  128.             this.tT_0._y = int((- this.nHeight) / 2 + PopUp.nOffset_x);
  129.             this.tT_1._y = int((- this.nHeight) / 2 + PopUp.nOffset_x * 2);
  130.             this.tT_2._y = int((- this.nHeight) / 2 + PopUp.nOffset_x);
  131.             this.bt_Y.release = function()
  132.             {
  133.                var _loc3_ = this._parent.tT_2.tTxt.text;
  134.                if(_loc3_.length > 0)
  135.                {
  136.                   Global.SUBMIT(_loc3_,this._parent.aSt[1]);
  137.                   Global.mTemp = _root.attachMovie("PopUp","PopUp" + _root.getNextHighestDepth(),_root.getNextHighestDepth(),{sFrame:"message",aSt:["SENDING..."]});
  138.                   Global.SUBMITEND = function()
  139.                   {
  140.                      Global.mTemp.remove();
  141.                      _root.attachMovie("PopUp","PopUp" + _root.getNextHighestDepth(),_root.getNextHighestDepth(),{sFrame:"ok",aSt:["VIEW HIGHSCORE?"],rtFun:function(_b)
  142.                      {
  143.                         if(_b)
  144.                         {
  145.                            Global.VIEWSCORE();
  146.                         }
  147.                         return true;
  148.                      }});
  149.                   };
  150.                   this._parent.remove();
  151.                }
  152.                else
  153.                {
  154.                   _root.attachMovie("PopUp","PopUp" + _root.getNextHighestDepth(),_root.getNextHighestDepth(),{sFrame:"ok",aSt:["ENTER A NAME PLEASE!"]});
  155.                }
  156.             };
  157.             break;
  158.          case "message":
  159.             this.nWidth = PopUp.nWidth_s;
  160.             this.tT_0._x = 0;
  161.             this.tT_0.tTxt._width = this.nWidth - PopUp.nOffset_x;
  162.             this.tT_0.replace();
  163.             this.nHeight = int(Math.max(PopUp.nHeight_s,this.tT_0.tTxt.textHeight + PopUp.nOffset_x * 2));
  164.             this.tT_0._y = - int(PopUp.nOffset_x / 2 + this.tT_0.tTxt.textHeight / 2);
  165.       }
  166.       this.bt_X.release = function()
  167.       {
  168.          this._parent.rtFun(false);
  169.          this._parent.remove();
  170.       };
  171.       this.mBar._width = this.nWidth;
  172.       this.mBar._height = this.nHeight;
  173.       this.mBar._x = (- this.nWidth) / 2;
  174.       this.mBar._y = (- this.nHeight) / 2;
  175.       this.stop();
  176.    }
  177.    function rtFun(_b)
  178.    {
  179.       return true;
  180.    }
  181.    function remove()
  182.    {
  183.       this.removeMovieClip();
  184.    }
  185. }
  186.