Listing 1
#include "NetServices.as"
#include "DataGlue.as"

// Init stuff
if (inited == undefined) {
inited = true;
// Set change handler for first combobox
dept_cb.setChangeHandler("employeesRefresh");
// Configure connection to ColdFusion
var gwURL = "http://localhost:8500/flashservices/gateway";
NetServices.setDefaultGatewayURL(gwURL);
gw = NetServices.createGatewayConnection();
employeeService = gw.getService("cfflash.employees", this);
// Invoke the GetDepartments method
employeeService.GetDepartments();
}

// dept_cb change handler
function employeesRefresh() {
// Invoke GetEmployees method
employeeService.GetEmployees(dept_cb.getSelectedItem().data);
}

// Process retrieved departments
function GetDepartments_Result(result) {
// Populate dept_cb with results
DataGlue.bindFormatStrings(dept_cb,result,"#DepartmentName#",
"#DepartmentID#");
}

// Process retrieved employees
function GetEmployees_Result(result) {
// Populate emp_cb with results
DataGlue.bindFormatStrings(emp_cb,result,"#lastname#, 
#firstname#","#employeeid#");
}

// Process submit button pressed
submit_btn.onrelease = function () {
EmployeeID = emp_cb.getSelectedItem().data;
getURL("action.cfm", "", "POST");
}