Skip to main content
calmchessplayer
Inspiring
November 24, 2009
Question

client side RSO send function questions

  • November 24, 2009
  • 1 reply
  • 400 views

I'm using the send method to send a  message from server to client wich is all fine and dandy but the problem is if i try to call another function from the called function it doesn't execute here is some code to demonstrate it......is the function out of scope of the rest of the application or something since it was executed by the FMS server? I'm sure the function i'm calling works becuase it works from outside the send  called fuctions

public function StopTimer():void{
  
timekeeper1.stopTicking();
trace("stopped ticking");
  }

    This topic has been closed for replies.

    1 reply

    November 25, 2009

    If you're using AS3, the scope of the function is the client object of the SharedObject. To handle getting events out to classes outside that scope, I like to write a class that extends eventdispatcher, and use an instance of that class as the SharedObject's client. Something along the lines of

    class SOClient extends EventDispatcher{

    public function SOClient(){

    }

    public function stopTimer(){

    dispatchEvent(new Event("STOP"));

    }

    }

    Then, I'll set up my app like so:

    var soClient:SOClient = new SOClient();

    soClient.addEventListener("STOP", stopHandler);

    var so = SharedObject.getRemote(blah, blah, blah);

    so.client - soClient;

    function stopHandler(e:Event){

         timekeeper1.stopTicking();

    }