This commit is contained in:
2014-07-06 20:33:21 +04:00
parent 6623a031d0
commit c7ac39a3bd
7 changed files with 41 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
package ru.m.armageddon.client.frames;
import flash.net.SharedObject;
import ru.m.armageddon.proto.ErrorResponse;
import protohx.Message;
import haxework.frame.IFrameSwitcher;
@@ -18,13 +19,25 @@ class AuthFrame extends VGroupView implements IPacketHandler {
public static inline var ID = "auth";
private var so:SharedObject;
private var loginInput:InputView;
private var passwordInput:InputView;
public function new() {
super();
so = SharedObject.getLocal("auth", "/");
}
public function init():Void {
findViewById("auth", ButtonView).onPress = this;
findViewById("password:input", InputView).textField.displayAsPassword = true;
loginInput = findViewById("login:input");
passwordInput = findViewById("password:input");
passwordInput.textField.displayAsPassword = true;
if (so.data.login != null && so.data.password != null) {
loginInput.text = so.data.login;
passwordInput.text = so.data.password;
}
}
public function onShow():Void {
@@ -32,8 +45,8 @@ class AuthFrame extends VGroupView implements IPacketHandler {
}
public function onPress(view:ButtonView):Void {
var login:String = findViewById("login:input", InputView).text;
var password:String = Md5.encode(findViewById("password:input", InputView).text);
var login:String = loginInput.text;
var password:String = Md5.encode(passwordInput.text);
var connection:IConnection = Provider.get(IConnection);
connection.connect()
.success(function(_) {
@@ -46,6 +59,9 @@ class AuthFrame extends VGroupView implements IPacketHandler {
}
public function onLoginResponse(packet:LoginResponse):Void {
so.setProperty("login", loginInput.text);
so.setProperty("password", passwordInput.text);
so.flush();
Provider.get(IFrameSwitcher).change("person");
}