Skip to main content
Inspiring
November 14, 2008
Answered

using a responder with a netconnection

  • November 14, 2008
  • 1 reply
  • 520 views
I'm using Flex and trying to call FMS3 over a netconnection. I want the responder to return values to Flex.

Basically I just make a call

theNetConnection.call ( "myFunction", new Responder ( hadSuccess, wasFailure) );

private function hadSuccess( returnedValue:Object) {
Alert.show ( returnedValue.toString () );
}
private function wasFailure( failure:Object) {
Alert.show ( failure.toString()
}

Then on the server roughly......
myFunction = function ( ){
return "It worked";
}

The server gets called and then the responder gets called with success, but there is never any value returned. What am I missing?????????
    This topic has been closed for replies.
    Correct answer jonpor
    I figured it out. Thought the problem looked familiar. Pulled my hair out on this one before as well.

    But.. I'll post the solution because I know I'll be looking for the same answer again in a month ;).

    In FMS I am using components. When the client is added to the component, this sets up the proxy/path to recieve calls from the client.

    i.e.
    myComponent.prototype.addClient( client ) {
    [..snip...]
    myproxy.someCallFromClient = function ( var1, var2 ) {
    this.mySomeCallFromClient(var1, var2);
    }
    [..snip...]
    }
    myComponent.prototype.mySomeCallFromClient( var1, var2) {
    return "Hello Word";
    }

    See what I'm missing? Yah I always miss it too....

    myproxy.someCallFromClient = function ( var1, var2 ) {
    ***RETURN*** this.mySomeCallFromClient(var1, var2);
    }

    Always forget to add the return to the proxy in the addclient!! grrr..

    Well at least the next time i search for this answer, I'll find my answer!

    1 reply

    jonporAuthorCorrect answer
    Inspiring
    November 14, 2008
    I figured it out. Thought the problem looked familiar. Pulled my hair out on this one before as well.

    But.. I'll post the solution because I know I'll be looking for the same answer again in a month ;).

    In FMS I am using components. When the client is added to the component, this sets up the proxy/path to recieve calls from the client.

    i.e.
    myComponent.prototype.addClient( client ) {
    [..snip...]
    myproxy.someCallFromClient = function ( var1, var2 ) {
    this.mySomeCallFromClient(var1, var2);
    }
    [..snip...]
    }
    myComponent.prototype.mySomeCallFromClient( var1, var2) {
    return "Hello Word";
    }

    See what I'm missing? Yah I always miss it too....

    myproxy.someCallFromClient = function ( var1, var2 ) {
    ***RETURN*** this.mySomeCallFromClient(var1, var2);
    }

    Always forget to add the return to the proxy in the addclient!! grrr..

    Well at least the next time i search for this answer, I'll find my answer!