home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / global_r.swf / scripts / __Packages / SendAFriend.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  3.8 KB  |  123 lines

  1. class SendAFriend extends MovieClip
  2. {
  3.    var onEnterFrame;
  4.    var sURL;
  5.    var tfFriendsName;
  6.    var tfFriendsEmail;
  7.    var tfYourName;
  8.    var tfYourEmail;
  9.    var btnSend;
  10.    var btnBack;
  11.    var oEnterLst;
  12.    var mcBlockade;
  13.    var mcYourEmail;
  14.    var mcYourName;
  15.    var mcFriendsEmail;
  16.    var mcFriendsName;
  17.    function SendAFriend()
  18.    {
  19.       super();
  20.       this.onEnterFrame = this.init;
  21.    }
  22.    function init(Void)
  23.    {
  24.       this.onEnterFrame = null;
  25.       this.sURL = Application.sBasePath + "TellAFriend.php";
  26.       this.tfFriendsName.tabIndex = 0;
  27.       this.tfFriendsEmail.tabIndex = 1;
  28.       this.tfYourName.tabIndex = 2;
  29.       this.tfYourEmail.tabIndex = 3;
  30.       this.tfFriendsEmail.restrict = "A-Za-z0-9_.@\\-";
  31.       this.tfYourEmail.restrict = "A-Za-z0-9_.@\\-";
  32.       this.btnSend.onRelease = mx.utils.Delegate.create(this,this.onReleaseSend);
  33.       this.btnBack.onRelease = mx.utils.Delegate.create(this,this.onReleaseBack);
  34.       this.oEnterLst = new Object();
  35.       this.oEnterLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressKey);
  36.       Key.addListener(this.oEnterLst);
  37.       Selection.setFocus(this.tfFriendsName);
  38.       Key.removeListener(Interface.getInstance().oSpaceLst);
  39.    }
  40.    function onReleaseSend(Void)
  41.    {
  42.       if(this.tfFriendsName.length > 0)
  43.       {
  44.          if(this.tfFriendsEmail.length > 0 && this.checkEmail(this.tfFriendsEmail.text))
  45.          {
  46.             if(this.tfYourName.length > 0)
  47.             {
  48.                if(this.tfYourEmail.length > 0 && this.checkEmail(this.tfYourEmail.text))
  49.                {
  50.                   this.mcBlockade.gotoAndStop("show");
  51.                   var _loc2_ = new LoadVars();
  52.                   _loc2_.SENDERNAME = this.tfYourName.text;
  53.                   _loc2_.SENDEREMAIL = this.tfYourEmail.text;
  54.                   _loc2_.RECEIPIENTNAME = this.tfFriendsName.text;
  55.                   _loc2_.RECEIPIENTEMAIL = this.tfFriendsEmail.text;
  56.                   _loc2_.MESSAGE = "";
  57.                   _loc2_.onLoad = mx.utils.Delegate.create(this,this.onLoadEmail);
  58.                   _loc2_.sendAndLoad(this.sURL,_loc2_,"POST");
  59.                   Key.removeListener(this.oEnterLst);
  60.                }
  61.                else
  62.                {
  63.                   this.mcYourEmail.gotoAndPlay("error");
  64.                   Selection.setFocus(this.tfYourEmail);
  65.                   Selection.setSelection(0,this.tfYourEmail.length);
  66.                }
  67.             }
  68.             else
  69.             {
  70.                this.mcYourName.gotoAndPlay("error");
  71.                Selection.setFocus(this.tfYourName);
  72.             }
  73.          }
  74.          else
  75.          {
  76.             this.mcFriendsEmail.gotoAndPlay("error");
  77.             Selection.setFocus(this.tfFriendsEmail);
  78.             Selection.setSelection(0,this.tfFriendsEmail.length);
  79.          }
  80.       }
  81.       else
  82.       {
  83.          this.mcFriendsName.gotoAndPlay("error");
  84.          Selection.setFocus(this.tfFriendsName);
  85.       }
  86.    }
  87.    function onLoadEmail(bSuccess)
  88.    {
  89.       if(bSuccess)
  90.       {
  91.          this.mcBlockade.gotoAndPlay("sent");
  92.       }
  93.       else
  94.       {
  95.          this.mcBlockade.gotoAndPlay("error");
  96.       }
  97.       Key.addListener(this.oEnterLst);
  98.    }
  99.    function onPressKey(Void)
  100.    {
  101.       if(Key.isDown(13))
  102.       {
  103.          this.onReleaseSend();
  104.       }
  105.    }
  106.    function checkEmail(sEmail)
  107.    {
  108.       var _loc4_ = sEmail.lastIndexOf(".");
  109.       var _loc2_ = sEmail.indexOf("@");
  110.       var _loc3_ = sEmail.indexOf(" ");
  111.       var _loc5_ = sEmail.lastIndexOf("..");
  112.       if(_loc3_ < 0 && _loc2_ > 0 && _loc2_ + 1 < _loc4_ && _loc5_ == -1)
  113.       {
  114.          return true;
  115.       }
  116.       return false;
  117.    }
  118.    function onReleaseBack(Void)
  119.    {
  120.       Interface.getInstance().onReleaseSendBack();
  121.    }
  122. }
  123.