Ez muy engorroso, s�, aunque yo estaba trabajando en algo as� para Remoting, porque la 
manera de recoger los resultados de las llamadas a m�todos remotos me romp�an un poco 
la estructura de m�s objetos.

Buscaba m�s flexibilidad a la hora de decidir qu� objetos y con qu� m�todos responder 
a un resultado o a un estado de la llamada a un m�todo remoto, as� que empec� a mapear 
m�todos de una manera un poco cutre.

Parece que el Callbackifizer va bien para esto, aunque te obliga a escribir un poco de 
c�digo extra. He hecho de memoria el c�digo siguiente as� que seguro que no funciona, 
pero supongo que sirve para hacerse a la idea -_-U

<code>

#include "Callbackifizer.as"


if (remoteResponseHandler == null) {
        remoteResponseHandler = function () {
                this.init();
        };
}
var o = remoteResponseHandler.prototype;

if (Callbackifizer == null) {
        trace("Error : Callbackifizer not Found");
} else {
        Callbackifizer.initialize(o);
}
o.init = function() {
        this._callbacks = new Object();
};
o.onResult = function(result) {
        this.executeCallBacks("onResult", arguments.concat());
};
o.onStatus = function(error) {
        this.executeCallBacks("onStatus", arguments.concat());
};


if (remoteMethodHandler == null) {
        _global.remoteMethodHandler = function() {
                this.init();
        };
}
remoteMethodHandler.prototype.init = function() {
        this.methodTable = new Object();
};
remoteMethodHandler.prototype.addMethodResponder = function(meth, o, onResultFunc, 
onStatusFunc) {
        if (this.methodTable[meth] == null) {
                this.methodTable[meth] = new remoteResponseHandler();
        }
        if (onResultFunc !=null) this.methodTable[meth].addCallBack("onResult", o, 
onResultFunc);
        if (onStatusFunc !=null)this.methodTable[meth].addCallBack("onStatus", o, 
onStatusFunc);
};
remoteMethodHandler.prototype.removeMethodResponder = function(meth, o, onResultFunc, 
onStatusFunc) {
        if (this.methodTable[meth] == null) {
                return false;
        }
        if (onResultFunc !=null) this.methodTable[meth].removeCallBack("onResult", o, 
onResultFunc);
        if (onStatusFunc !=null) this.methodTable[meth].removeCallBack("onStatus", o, 
onStatusFunc);
};
remoteMethodHandler.prototype.getResponseHandler = function(meth) {
        return this.methodTable[meth];
};
/*
NetServices.setDefaultGatewayURL("http://localhost/flashremoting/gateway.aspx";);
mainConnection = NetServices.createGatewayConnection();
mainService = mainConnection.getService("timekeeper.Interface");

o1 = new Object();
o1.meth1 = function (result) { "o1 getting the result : "+result;}
o2 = new Object();
o2.meth1 = function (result) { "o1 getting the result : "+result;}
o3 = new Object();
o3.meth1= function (error) { "o3 getting the error : "+error+ " : "+error.description;}

a = new remoteMethodHandler();
a.addMethodResponder("getUserPrivileges", o1, "meth1");
a.addMethodResponder("getUserPrivileges", o2, "meth1");
a.addMethodResponder("getUserPrivileges", o3, null, "meth1");

mainService.getUserPrivileges(a.getResponderHandler("getUserPrivileges"), param1, 
param2, param3);

*/
</code>


On Wed, 2 Jul 2003 12:03:26 +0200, Joseba Alonso wrote
> He visto esta tecnica en el blog de Bokel. Una interesante manera de 
> tratar eventos. Es una mezcla entre callbacks y listeners. A ver que 
> os parece. A mi me parece interesante, pero quizas un poco engorroso...
> 
> http://www.helpqlodhelp.com/blog/archives/000047.html
> 
> un saludo
> 
> Joseba Alonso
> www.sidedev.net
> 
> <!-------------------------------
> Lista ASNativos:
> subscripciones/desubscripciones
> http://www.sidedev.net/asnativos
> -------------------------------->




<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->

Responder a