MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Especificaciones Pagina 173

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 369
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 172
Application Server Connectivity 95
3 Create a global object to hold the recordset.
// An object to hold your service and recordset
gFoo = {};
4
Get a reference to the foo service.
// Get a named service
gFoo.service = gRemotingGateway.getService("foo", gFoo);
5
Create the onResult callback, which the Flash Remoting service expects.
// Set up the onResult callback and call it bar_Result.
// The function must be named such that if you call
// xxx method on the foo service, it will result in
// xxx_Result method being called. You set the data in
// the shared object so the Flash client can display it.
gFoo.bar_Result = function(result) {
var cols = result.getColumnNames();
trace("Columns: " + cols);
gRecords.setProperty("__COLUMNS__", cols);
var reclen = result.getLength();
trace("number of records " + reclen);
for (var i = 0; i < reclen; i++) {
trace(i + "] " + result.getItemAt(i));
gRecords.setProperty(i, result.getItemAt(i));
}
}
6
In the onConnect function, accept the client’s connection.
application.onConnect = function(client) {
trace(application.name + " connect from " + client.ip);
application.acceptConnection(client);
}
7
Provide a prototype function that the client can call to get the records.
Client.prototype.getRecords = function() {
// Call the bar method on foo service
var result = gFoo.service.bar();
trace("gFoo.service.bar returned " + result);
}
8
Save the file as main.asc in a doc_rset directory under the flashcom applications directory.
Note: Save this main.asc file where you’ve chosen to store your server-side application files. For more
information see Chapter 1, “The flashcom application directory,” on page 15.
To write the ColdFusion component for this sample:
1 Using your standard editor, create a new file and add code to query the database for all records.
<cfquery name="flash.result" datasource="ExampleApps">
SELECT * FROM tblItems
</cfquery>
2
Save the file as bar.cfm in the foo directory under the directory where you publish all of your
ColdFusion MX files.
Vista de pagina 172
1 2 ... 168 169 170 171 172 173 174 175 176 177 178 ... 368 369

Comentarios a estos manuales

Sin comentarios