all groups > macromedia flash flash remoting > may 2004 >
You're in the

macromedia flash flash remoting

group:

Remoting with ActionScriptV2


Remoting with ActionScriptV2 Gundja
5/24/2004 2:11:35 PM
macromedia flash flash remoting:
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
Re: Remoting with ActionScriptV2 Gundja
5/24/2004 4:02:22 PM
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 !

AddThis Social Bookmark Button