MACROMEDIA FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 Use Manual page 31

Using flash remoting for flash mx 2004 actionscript 2.0
Table of Contents

Advertisement

Configure Flash Remoting (create a gateway and a reference to a remote service).
5.
Call service functions and pass parameters.
6.
Handle the results and error status information returned to Flash in result event-handler
7.
routines.
The following ActionScript example connects to the
creates the
catalogService
and
getCategories()
result-handler callback methods,
show the results in the Flash application. They also has corresponding fault-handler callback
methods,
gotCategories_Fault()
information if the service call fails.
Import Flash
Remoting
ActionScript
classes
Configure Flash
Remoting
Call the service
function(s)
callback functions
handle returned
result and fault
information
Service object, and calls two service functions,
catalogService.getProducts()
gotCategories_Result()
and
got_Categories_Result()
import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent;
// Remove the slashes in the following two lines to use the
NetConnection Debugger
// import mx.remoting.debug.NetDebug;
// NetDebug.initialize();
function makePetMarketCalls(){
var catalogService:Service = new Service(
"http://examples.macromedia.com/flashservices/gateway",
new Log(),
"petmarket.api.catalogservice",
null,null );
var cat_pc:PendingCall =
catalogService.getCategories({locale:"en_US"});
cat_pc.responder = new RelayResponder(this,"gotCategories_Result",
"gotCategories_Fault");
var prod_pc:PendingCall = catalogService.
getProducts({categoryoid:5});
prod_pc.responder = new RelayResponder(this,"gotProducts_Result",
"gotProducts_Fault");
}
function gotCategories_Result(re:ResultEvent):Void{
trace("Got " + re.result.length + " Categor" + (re.result.
length>1?"ies":"y"));
}
function gotCategories_Fault(fault:FaultEvent):Void{
trace("Categories Fault: " + fault.fault.description);
}
function gotProducts_Result(re:ResultEvent):Void{
trace("Got " + re.result.length + " Product" + (re.result.
length>1?"s":""));
}
function gotProducts_Fault(fault:FaultEvent):Void{
trace("Products Fault: " + fault.fault.description);
}
makePetMarketCalls();
petmarket.api.catalogservice
. These functions have corresponding
and
gotProducts_Result()
, to handle any error
Flash Remoting application structure
service,
catalogService.
to
31

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH REMOTING MX-USING FLASH REMOTING FOR FLASH MX 2004 ACTIONSCRIPT 2.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash remoting mx

Table of Contents