![MACROMEDIA FLASH REMOTING MX Use Manual Download Page 27](http://html1.mh-extra.com/html/macromedia/flash-remoting-mx/flash-remoting-mx_use-manual_687566027.webp)
Migrating existing applications to Flash Remoting for Flash MX 2004 ActionScript 2.0
27
// maps result fields to the comboBox dataProvider; name is the label
// field and categoryId is the data field.
DataGlue.bindFormatStrings(combo, result.result, "#name#",
"#categoryId#");
// dispatch a change event for the dataGrid to be updated.
combo.dispatchEvent({type:"change", target:combo});
}
function gotCatStatus(fault:FaultEvent)
{
trace(" Error : "+ fault.fault.faultstring);
}
You can set up the Responder object in one of the following two ways:
■
The Service constructor passes its name, in which cases it becomes the default handler for
the result and fault outcomes of any method called for the service.
■
The call to the service method specifies the Responder object that will handle the result or
fault only for that specific method invocation. The example uses this approach, using a
RelayResponder object to specify the result handling and fault handling methods for the
getCategories()
service function.
7.
Register a listener for the
combo
ComboBox and set up a responder object for the second service
method call to the
getProductsByCategory()
function, which will fetch the detail records
based on the items selected in the ComboBox. The parameter for the
getProductsByCategory()
function is the
selectedItem.data
field.
myChangeObj = new Object();
myChangeObj.change = function(evt:Object)
{
// the textArea should be set to empty once new categories are being fetched,
// so that it does not show any old data
details.text = "";
myService.getProductsByCategory(Number(evt.target.getValue())).responder
= new RelayResponder(_root, "catResult" , "catFault");
}
combo.addEventListener("change", myChangeObj);
function catResult(result)
{
// set up the grid.dataProvider based on the results from
// getProductsByCategory()
grid.dataProvider = result.result;
}
function catFault(error)
{
trace(" received fault ");
}