Hi Tim,
Thanks for the reply and example, I had already managed to get it working and
here's the code, might help someone else :)
I had found my answer in
Macromedia? Flash? Professional 8 UNLEASHED
By David Vogeleer, Eddie Wilson, Lou Barber
...............................................
Publisher: Sams
Pub Date: October 12, 2005
ISBN: 0-672-32761-9
I hope to build on this experience over time as I think Remoting is pretty
cool stuff.
Basically just a combo and List boxes passing argument from combo to populate
the list box.
*******************************
<!--- Use for testing if you can connect remotely --->
<CFFUNCTION NAME="getTestConn" HINT="Get a test connection" ACCESS="remote"
RETURNTYPE="string">
<CFRETURN ".....connection sucessful">
</CFFUNCTION>
<CFFUNCTION NAME="ListDepts" HINT="Get a List of departments" ACCESS="remote"
RETURNTYPE="query">
<CFQUERY DATASOURCE="exampleapps" NAME="dept">
SELECT * FROM tblDepartments
ORDER BY DepartmentName
</CFQUERY>
<CFRETURN dept>
</CFFUNCTION>
<!--- Obtain department employees --->
<CFFUNCTION NAME="ListByDept" HINT="Get employees based on department"
ACCESS="remote" RETURNTYPE="query">
<CFARGUMENT NAME="DepartmentID" TYPE="string" REQUIRED="yes">
<CFQUERY DATASOURCE="exampleapps" NAME="emps">
SELECT * FROM tblEmployees
WHERE DeptIDFK = '#ARGUMENTS.DepartmentID#'
ORDER BY LastName, FirstName
</CFQUERY>
<CFRETURN emps>
</CFFUNCTION>
*******************************
// Import the Flash Remoting Classes
import mx.remoting.Service;
import mx.services.Log;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent;
import mx.remoting.DataGlue;
//Connect to the gateway
var myService:Service = new Service(
"http://localhost/flashservices/gateway",
new Log(Log,DEBUG),
"cfflash1.employee",
null,
null );
// Test the connection
function getTestConn() {
// create a Pending Call object
var testConn_pc:PendingCall = myService.getTestConn();
//Use the responder property to handle success or failure
testConn_pc.responder = new
RelayResponder(this,"getTestConn_Result","getTestConn_Fault");
}
// Handle the success
function getTestConn_Result(re:ResultEvent){
//trace(re.result);
pageTitle.text = re.result;
//Call the listDepts function to start the application
listDepts();
}
// Handle a failure
function getTestConn_Fault(re:FaultEvent){
trace(" An error has occurred");
}
// get the countries
function listDepts(){
// call service function
var departments_pc:PendingCall = myService.listDepts();
departments_pc.responder = new
RelayResponder(this,"listDepts_Result","listDepts_Fault");
}
function listDepts_Result(re:ResultEvent){
trace("Got Depts - " + re.result.length + " Records" );
// display successful result in the combo box
DataGlue.bindFormatStrings(depts_cb,re.result,"#DepartmentName#","#DepartmentID
#");
}
function listDepts_Fault (fe:FaultEvent):Void {
trace("DeptsCallFailed-");
}
//get the employees for the selected dept
function listByDept(departmentId){
var employeesDetails_pc:PendingCall = myService.listByDept(departmentId);
employeesDetails_pc.responder = new
RelayResponder(this,"listByDept_Result","listByDept_Fault");
}
function listByDept_Result (re:ResultEvent)
{
//trace("Got employees - " + re.result.length + " Records" );
// display successful result in the list box
DataGlue.bindFormatStrings(employees_lb,re.result,"#LastName","#LastName#");
}
function listByDept_Fault (re:FaultEvent) {
trace("Got an error");
}
// create an event handler for the dropdown box
var onDeptChangeListener :Object = new Object();
this.onDeptChangeListener.change = function()
{
var departmentId:String = depts_cb.selectedItem.data;
listByDept(departmentId);
}
this.depts_cb.addEventListener("change", onDeptChangeListener);
// Start the application
getTestConn();