ioa
07-29-2003, 05:45 PM
Hello all.
I,m having a little problem with flash remoting.
I can't call two differents functions or services.
Lets try to explanin better.
In Movie_1 I call service 1. When testing it standalone it works.
In Movie_2 I call service 2. When testing it standalone it works.
Movie 3 calls Movie 1 and the service 1 runs Ok but when Movie 3 calls Movie 2 then services 2 do not run. Movie 3 calls back Movie 1 and
service 1 runs.
And the other way around doesn't work either. Example:
Movie 3 calls Movie 2 and the service 2 runs Ok but when Movie 3 calls Movie 1 then services 1 do not run. Movie 3 calls back Movie 2 and
service 2 runs.
Here is the code.
In order to reuse some code I create this include file:
// ************* The connection Stuff **********************
//The file name is connectionScript.as
#include "NetServices.as"
//Setting the service connection Object
// Only create the connection Obj if the connection Object do no exist
if (_global._gatewayConnectionOpen == undefined || _global._gatewayConnection == false) {
initConnection();
}
//Create the connection object
function initConnection() {
NetServices.setDefaultGatewayURL("http://localhost/myUrl/gateway.aspx");
//Make the serviceConnection Object global so it could be reused later
_global.serviceConnection = NetServices.createGatewayConnection();
// A flag to check if the connection has been open
_global._gatewayConnectionOpen = true;
}
/* ***********************************************
*************** Getting remote Objects *******
************************************************* */
//General function to create objects
function getRemoteObject(remoteObj, serviceName) {
if (remoteObj == undefined || remoteObj == null ) {
remoteObj = _global.serviceConnection.getService(serviceName);
}
return globalObj
}
function setRemoteObject1() {
//Make this object globlal so it could be reused later in other movies.
_global._remoteObject1 = getRemoteObject(_global._remoteObject1 , "Service1")
}
function setRemoteObject2() {
//Make this object globlal so it could be reused later in other movies.
_global._remoteObject2 = getRemoteObject(_global._remoteObject2 , "Service2")
}
I have also create another include file to handling service results
The file name is resultHandle.as
//Defining the return Object
// General result handler object
function obj_resultHandler ()
{
this.onResult = function (result)
{
doSomething(result);
}
this.onStatus = function (status)
{
trace (status.description)
}
}
So in my Movie 1 I have something like:
//including the resultHandle
#include resultHandle.as
//including the connection script
#include connectionScript.as
//Creating the remote Object 1 that will call service 1
setRemoteObject1();
//Calling the function that service1 provide and passing the obj_resultHandler as the response object
_global._remoteObject1.function1(new obj_resultHandler());
//All this works if call stand alone.
For movie 2 is the same thing:
/including the resultHandle
#include resultHandle.as
//including the connection script
#include connectionScript.as
//Creating the remote Object 1 that will call service 2
setRemoteObject2();
//Calling the function that service1 provide and passing the obj_resultHandler as the response object
_global._remoteObject2.function2(new obj_resultHandler());
//All this works if call stand alone.
Any idea what is wrong? I know this is a little bit large but any help will be appreciated.
Thanks in advance.
I,m having a little problem with flash remoting.
I can't call two differents functions or services.
Lets try to explanin better.
In Movie_1 I call service 1. When testing it standalone it works.
In Movie_2 I call service 2. When testing it standalone it works.
Movie 3 calls Movie 1 and the service 1 runs Ok but when Movie 3 calls Movie 2 then services 2 do not run. Movie 3 calls back Movie 1 and
service 1 runs.
And the other way around doesn't work either. Example:
Movie 3 calls Movie 2 and the service 2 runs Ok but when Movie 3 calls Movie 1 then services 1 do not run. Movie 3 calls back Movie 2 and
service 2 runs.
Here is the code.
In order to reuse some code I create this include file:
// ************* The connection Stuff **********************
//The file name is connectionScript.as
#include "NetServices.as"
//Setting the service connection Object
// Only create the connection Obj if the connection Object do no exist
if (_global._gatewayConnectionOpen == undefined || _global._gatewayConnection == false) {
initConnection();
}
//Create the connection object
function initConnection() {
NetServices.setDefaultGatewayURL("http://localhost/myUrl/gateway.aspx");
//Make the serviceConnection Object global so it could be reused later
_global.serviceConnection = NetServices.createGatewayConnection();
// A flag to check if the connection has been open
_global._gatewayConnectionOpen = true;
}
/* ***********************************************
*************** Getting remote Objects *******
************************************************* */
//General function to create objects
function getRemoteObject(remoteObj, serviceName) {
if (remoteObj == undefined || remoteObj == null ) {
remoteObj = _global.serviceConnection.getService(serviceName);
}
return globalObj
}
function setRemoteObject1() {
//Make this object globlal so it could be reused later in other movies.
_global._remoteObject1 = getRemoteObject(_global._remoteObject1 , "Service1")
}
function setRemoteObject2() {
//Make this object globlal so it could be reused later in other movies.
_global._remoteObject2 = getRemoteObject(_global._remoteObject2 , "Service2")
}
I have also create another include file to handling service results
The file name is resultHandle.as
//Defining the return Object
// General result handler object
function obj_resultHandler ()
{
this.onResult = function (result)
{
doSomething(result);
}
this.onStatus = function (status)
{
trace (status.description)
}
}
So in my Movie 1 I have something like:
//including the resultHandle
#include resultHandle.as
//including the connection script
#include connectionScript.as
//Creating the remote Object 1 that will call service 1
setRemoteObject1();
//Calling the function that service1 provide and passing the obj_resultHandler as the response object
_global._remoteObject1.function1(new obj_resultHandler());
//All this works if call stand alone.
For movie 2 is the same thing:
/including the resultHandle
#include resultHandle.as
//including the connection script
#include connectionScript.as
//Creating the remote Object 1 that will call service 2
setRemoteObject2();
//Calling the function that service1 provide and passing the obj_resultHandler as the response object
_global._remoteObject2.function2(new obj_resultHandler());
//All this works if call stand alone.
Any idea what is wrong? I know this is a little bit large but any help will be appreciated.
Thanks in advance.