Invoking a Macromedia Flash Function from SSAS

These scripts will define a function on the Flash client and call it from the server. Functions are defined as methods in the NetConnection object on the client. They are called from the Client object in SSAS.

The ActionScript in Listing E.17 defines a function in Flash called sayHelloClient. It will be called by SSAS in Listing E.18.

Listing E.17 Flash ActionScript for Defining a Flash Function
nc = new NetConnection();
nc.connect("rtmp://localhost/myApplication/myInstance");

// Define the Function that the server will call in the NetConnection
nc.sayHelloClient = function() {
      trace("The Server says.. Yo, Dude!");
};

The ActionScript in Listing E.18 calls the client function set in Listing E.17.

Listing E.18 Server-Side ActionScript (main.asc) for Calling the Client Function
application.onConnect = function(clientObject) {
      application.acceptConnection(clientObject);

      // invoke the function on the Client
      clientObject.call("sayHelloClient");
};


    Part I: 10 Quick Steps for Getting Started