1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| private var connection:NetConnection;
private var responder:Responder;
private var __email:String;
private var __password:String;
private static const GATEWAY:String = "http://localhost/amfphp/gateway.php";
//constructor
public function Login() {
setUpForm();
loginBtn.addEventListener(MouseEvent.CLICK, doLogin);
connection = new NetConnection();
responder = new Responder(handledoLogin, null);
connection.addEventListener(NetStatusEvent.NET_STATUS, errorConnection);
connection.addEventListener(IOErrorEvent.IO_ERROR, errorConnection);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorConnection);
connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorConnection);
connection.connect(Login.GATEWAY);
}
private function doLogin(pEvt:MouseEvent):void {
if (emailI.text !="" || passwordI.text !="") {
__email = emailI.text;
__password = passwordI.text;
connection.call("shopping.getClient", responder, __email, __password);
} else {
msg.text = "all fields are required!";
}
}
private function errorConnection(pEvt:Event):void {
trace(pEvt);
}
private function handledoLogin(re:Object):void {
if(re != null) {
trace(re);
} else {
msg.text = "invalid email/password";
}
} |
Partager