Hi,
I am trying to do Remoting with actionscript V2.
i've got a class which is the entry point of the application like that :
class Application {
static var globalGateway:NetConnection
public static function getGateway():NetConnection
{
if(this.globalGateway==null)
{
//initialize the gateway
}
return this.globalGateway;
}
}
whe i'am testing all is ok. So, next step, i want to invoke a .NET method an
trace the result of the method (very easy with as1.0, but here we are in v2....)
so i create a new class like :
class NewClass{
//constructor
function NewClass()
{
addEventListener("load", onLoad);
}
function onLoad():Void
{
var myConnection:NetConnection = Application.getGateway();
myConnection.getService("classpath");
myConnection.call("methodpath", this);
}
}
When i'm testing, the .NET's method is calling (good). But i don't find the
method to see the result in Flash !!?
Anyone to help me ?
when i add function onResult(result):Void, this method is never call, like
method_Result etc... I would apply the singleton pattern to my application
(next step).
Thanx
Gundja - 24 May 2004 17:02 GMT
OK i found :
TempObject = function(obj, objParent)
{
myConnection = obj;
myConnection.getService("classPath");
myConnection.call("methodPath", this);
this._parent = objParent;
}
TempObject.prototype._parent;
/* Invoke the .NET method */
var myConnection:NetConnection;
myConnection = Application.getGateway();
var myObject = new TempObject(myConnection, this);
myObject.onResult = function(result){_parent.handleResult(result);}
like that, i can handle the result in my parentObject and manage result with
object in my movieclip or application.
If anyone is interesting by the gobal code to add an abstract layer for the
remoting, don't hesitate to contact me !