
Application Server Connectivity 93
Sample 3: Recordset
Once you have easy access to a database, you add data storage and retrieval to your Flash
Communication Server. This simple test retrieves all the recordsets from a database. The work is
done by one SQL statement inside a CFM file.
About the sample
When the user clicks the Get Records button, all the data in the database appears in the list box.
Re-creating the sample
The doc_rset.fla file provides an interface in which the user simply selects the Get Records button
and the record set is returned.
See “Creating your working environment” on page 31 before you start to re-create the sample.
To create the user interface for this sample:
1 In the Flash MX authoring environment, select File > New to open a new file.
2 To add an element for listing records, open the Components panel (Windows > Components),
drag the List Box component onto the Stage, and give it the instance name
records_list.
3 To add the button for connecting to the server, drag a push button from the Components
panel onto the Stage. In the Property inspector, give it the instance name
GetRecs_btn, the
label
Get Records, and the click handler doGetRecords.
4 Create a directory named doc_rset in your flashcom application directory, and save the file as
doc_rset.fla in this directory.
To write the client-side ActionScript for this sample:
1 Create a new network connection and connect to the Flash Communication Server.
// Create a network connection and connect
nc = new NetConnection();
nc.onStatus = function(info) {
trace(info.level + ": " + info.code + " " + info.description);
}
nc.connect("rtmp:/doc_rset/room_01");
2
Get a shared object, and update the list box (records_list) with the data from the shared
object.
// Get the records from the records shared object
recset_so = SharedObject.getRemote("records", nc.uri, false);
recset_so.onSync = function(list) {
// Clear the list box
records_list.removeAll();
// Fill in the records, with column headers first. Use
// the getColumnString function, defined below, to get
// all of the column information.
records_list.addItem(getColumnString(this.data.__COLUMNS__), -1);
Commentaires sur ces manuels