
Chapter 594
3 In the same method, assign a variable name, recstr, for the data coming from the call to
getRecordString and populate the list box with the data.
for (var i in this.data) {
if (i == "__COLUMNS__")
continue;
var recstr = getRecordString(this.data[i], this.data.__COLUMNS__);
records_list.addItem(recstr, i);
}
records_list.sortItemsBy("data", "ASC");
}
4
Connect to the shared object.
recset_so.connect(nc);
5
Create the getColumnString function to get all the column data.
// Get a string out of all column headers
function getColumnString(cols) {
var colstr = "";
if (cols.length > 0)
colstr += cols[0];
for (var i = 1; i < cols.length; i++)
colstr += ", " + cols[i];
return colstr;
}
6
Create the getRecordString function.
// Get a string containing all records in column order
function getRecordString(inx, recs, cols) {
var recstr = "";
if (cols.length > 0)
recstr += recs[cols[0]];
for (var i = 1; i < cols.length; i++)
recstr += ", " + recs[cols[i]];
return recstr;
}
7
Create the event handler for the GetRecs_btn button. When the user clicks the button, the
doGetRecords method is called; this function contains the getRecords call defined in the
server-side ActionScript.
// Call the server to initiate a database query and place
// the recordset data in ’records’ shared object
function doGetRecords() {
nc.call("getRecords", null);
}
To write the server-side ActionScript for this sample:
1 Create a new file using your server-side ActionScript editor, and load the netservices.asc file to
enable Flash Remoting through the Flash Communication Server.
load("netservices.asc");
2
Get the records shared object.
gRecords = SharedObject.get("records", false);
// Set the default gateway URL
NetServices.setDefaultGatewayUrl("http://localhost:8500/flashservices/
gateway");
Commentaires sur ces manuels