I am reading the Oreilly book "Programming ColdFusion MX 6.2" by Rob
Brooks-Bilson. I have been programming CF for a few years, but I am new to the
Remoting Model. I updated my Flash 2004, and I am having trouble following the
examples in the book. My UI components don't operate in the same manor as the
ones in the book. THey even look different. For example, I am creating two
dynamic drop down boxes, when you select a name in the first box, it populates
the second box. Then you click on a pushbutton to retrieve all the user
information. Here is the code.
#include "NetServices.as"
#include "DataGlue.as"
#include "NetDebug.as"
// --------------------------------------------------
// Application initialization
// --------------------------------------------------
if (inited == null) {
// do this code only once
var inited = true;
// set the default gateway URL (this is used only in authoring)
NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway");
// connect to the gateway
var gateway_conn = NetServices.createGatewayConnection();
// get a reference to a service
var myService = gateway_conn.getService("programmingcf.ch28.employee", this);
}
// --------------------------------------------------
// cb1 combo box
// --------------------------------------------------
//call the getDepartments() method
myService.getDepartments();
//Bind the results to the cb1 combo box using data glue
function getDepartments_Result (result) {
DataGlue.bindFormatStrings(cb1, result, "#Department#", "#Department#");
}
// --------------------------------------------------
// cb2 combo box
// --------------------------------------------------
// When a selection in the first combo box is made, call showEmployees()
cb1.setChangeHandler("showEmployees");
function showEmployees(component){
cb2.removeAll( );
myService.getEmployees(cb1.getSelectedItem( ).data);
cb2.addItem("loading...","");
}
function getEmployees_Result(result) {
cb2.removeAll();
for (var i = 0;i < result.items.length;i++) {
cb2.addItem(result.items.Name,result.items.ID);
}
}
// --------------------------------------------------
// Button handler and full record get/display
// --------------------------------------------------
// Retrieve the full employee record based on the employee selected
function employeeHandler(){
myService.getEmployee(cb2.getSelectedItem( ).data);
}
// Display the full employee record
function getEmployee_Result(result) {
dName.text = result.items[0].Name;
dTitle.text = result.items[0].Title;
dDepartment.text = result.items[0].Department;
dEmail.text = result.items[0].Email;
dPhoneExt.text = result.items[0].phoneExt;
}
stop();
This works great if I use the example provided with the book (the code
downloaded from oreilly's website). But the drop down box looks different than
the one I have. I have two lists in the Components window "Flash UI Components
Set 2" and "UI Components". I am pulling them from the "UI Components" section.
Something I have noticed is that in my combo boxes, I can change the options
in the Component Inspector, but not in theirs. It is as if they are using an
older version of the boxes. That's fine, but how do I get the data to work with
mine? When I run the .swf file in Flash, they are blank, I don't even get the
drop down arrow. Clearly it is not bound to something it needs to be, right?
As always, thank you for educating me!
Pauly