• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Appendix: IV Appendixes: Quick Reference... > Connect a Database with Macromedia F...

Connect a Database with Macromedia Flash Remoting MX Using SSAS

The server-side ActionScript (SSAS) in Listing E.12 connects to a Flash Remoting MX service to perform a simple user login authentication. The service is defined when the application starts. A Service method is called and handled when the client connects. Remember, Flash Remoting MX is nonpersistent. A connection is established each time a service method is invoked.

Listing E.12. Server-Side ActionScript for Connecting a Database with Flash Remoting MX

// Load the NetServices Class Libraries
load(“netservices.asc”);
// When the application Starts, setup the non-persistent Flash Remoting server
application.onAppStart = function() {
      trace(“Application was loaded, Cap'n”);
      NetServices.setDefaultGatewayUrl(“http://localhost/flashservices/gateway”);
      var gatewayConnection = NetServices.createGatewayConnection();
      //  instantiate the service into a local variable
      var cf_service = gatewayConnection.getService (“myFlashComService.login_service”, this);
};

application.onConnect = function(clientObject, username, password) {
      // call the server function, authenticateUser, passing the username and password
      var callTheServer = cf_service.authenticateUser(username, password);
      // handle the server response
      this.authenticateUser_Result = function(result_rs) {
            trace(“The Server Responded  —> “+ result_rs.getLength());
            trace(“The firstName value of row 0  —> “+ result_rs.items[0].firstName);
            };
      // handle any server errors
      this.authenticateUser_Status = function(status) {
            trace(“Returned FAILED From the Server”);
      };
};


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint