To enable NetServices on the Flash Communication Server, you must load the NetServices.asc ActionScript file. Loading this file makes the NetServices and RecordSet libraries available to the server. Before you can connect with Remoting-enabled Application Servers using Flash Remoting MX, the following script must be placed in the main.asc file:
Unlike Flash MX, the Flash Communication Server does not require the Flash Remoting MX download from Macromedia.com.
The RecordSet object is packaged with NetServices and is available to both Flash MX and Flash Communication Server. A RecordSet is an ActionScript object that contains database columns (or fields) and rows (or records). Each row contains the values for each column that can be accessed by defining the row number and the column name. For example, to access the first name of a user that was returned in the sixth row of a database query, you would use one of the following:
var myVariable = myDB_rs.items[rowNumber].columnName;
var myVariable = myDB_rs.items.firstName;
If you are familiar with handling RecordSets from a database, or Application Server, you should be aware that Row #1 in Flash is referenced by the index 0, not 1. A total record count of 10 would have a maximum index of 9.
The RecordSet object includes a series of methods that you can use to interact with your database RecordSet. It has been built to simulate traditional methods used when handling RecordSets. Handling data returned from a database is much easier and manageable with this object.
For a complete list of methods available with NetServices, refer to Appendix B,"Macromedia Flash ActionScript Objects Quick Reference."
The RecordSet object is also available for Flash MX. If you place a RecordSet object within a Remote SharedObject as a slot of the data property, the Recordset will become available to all clients connected to the SharedObject. When accessing the RecordSet slot in Flash MX, you can interact with the data just as easily as you can in Flash Communication Server.
To enable the RecordSet methods, you must load the NetServices class.
To enable the RecordSet methods in Flash MX, you must have the Flash Remoting MX components installed, and then include the following script at the start of your Flash movie:
To enable the RecordSet methods on Flash Communication Server MX, you must include the following script in your main.asc file:
This was a brief overview of the Flash Remoting MX component. The exercises within this chapter will step you through the process of using Flash Remoting MX with the Flash Communication Server to authenticate a user against a database.