Example Name: Customers2.fla
Description: Utilizes .setDeliveryMode("ondemand",10)
Language: ActionScript 1.0
Version: 1.0.0
Code:
#include "NetServices.as"
NetServices.setDefaultGatewayURL("http://localhost/flashservices/gateway");
var my_conn = NetServices.createGatewayConnection();
var customerService = my_conn.getService("com.oreilly.frdg.Customers",this);
customerService.getCustomers2({pagesize:10});
// Declares the IncomingDataHandler object's constructor.
function IncomingDataHandler(rs) {
this.rs = rs;
}
// Get the rows that the server sent back immediately. Should be
// equal to the Flash.Pagesize variable set on the server.
IncomingDataHandler.prototype.getData = function() {
for (var i = 0; i < this.rs.getNumberAvailable(); ++i) {
trace(this.rs.getItemAt(i)["ContactName"]);
}
}
// This is the function that will automatically be
// called as data is returned from the server.
IncomingDataHandler.prototype.modelChanged = function (info) {
if (info.event == "updateRows") {
for (var i = info.firstRow; i <= info.lastRow; ++i) {
trace(this.rs.getItemAt(i)["ContactName"]);
}
}
}
function onResult(result) {
// Fetch only 10 records
result.setDeliveryMode("ondemand",10);
var dataHandler = new IncomingDataHandler(result);
result.addView(dataHandler);
dataHandler.getData();
}
function onStatus(error) {
trace("error: " + error.description);
}
Download code text
Download chapter example files