Código :
(PHP)
<?php
class SecuredConn
{
function SecuredConn()
{
$this->methodTable = array(
"welcome" => array(
"description" => "validate function",
"access" => "remote",
"roles" => "admin"
)
);
}
function _authenticate($user, $pass)
{
if ($user == "a" && $pass == "aa")
{
return "admin";
}
else
{
return false;
}
}
function welcome() {
return "bienvenido!!!!";
}
}
?>
Código :
(AS)
import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
//
stop();
var sSecured:Service = new Service("http://localhost/project/amfphp/gateway.php", null, "SecuredConn", null, null);
mx.remoting.debug.NetDebug.initialize(sSecured)
function welcomeResult(rs:ResultEvent) {
trace(rs.result);
}
function welcomeFault(fl:FaultEvent) {
trace("Su usuario no esta validado");
trace("Hubo un problema: "+fl.fault.faultstring);
trace("El código del error es: "+fl.fault.faultcode);
trace("Detalles: "+fl.fault.detail);
}
btnEntrar.onRelease = function()
{
svSecured.connection.setCredentials(tfUsuario.text, tfPassword.text);
var pcWelcome:PendingCall = sSecured.welcome();
pcWelcome.responder = new RelayResponder(this, "welcomeResult", "welcomeFault");
}
He colocado 2 text fields (tfUsuario y tfPassword) junto a un botón (btnEntrar). Al introducir "daniel" en usuario y "asfusion" en password... ¿por qué no me hace el trace de bienvenido al darle al botón?
Saludos!
