The NetDebug class lets you trace function calls, parameters, and results among the Flash application, Flash Remoting, and the application server. You use the NetConnection Debugger (NCD) panel in the Flash authoring environment to view the debugging results. To use the NetConnection Debugger and the NetDebug class, you must first do the following:
import mx.remoting.debug.NetDebug;
NetDebug.initialize() method before connecting to the service or calling any other debugging methods.NetDebug.initialize() method to initialize debug support, then connects to the CustomerInfo service and, if the debug flag has a value of true, it calls the NetDebug.trace() method to display a message in the NetConnection Debugger.
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.remoting.PendingCall;
import mx.remoting.debug.NetDebug;
import mx.services.Log;
var debug:Boolean = NetDebug.initialize();
var custService = new Service("http://custinfo/flashservices/gateway", new Log(), "CustomerInfo", null, null);
custService.getService("myService", this);
if(debug)
{
NetDebug.trace({level:"testing", message:"This is the message field of an object sent the NCD via trace"});
}
| Methods | |
static | initialize(
)
: BooleanInitializes the Flash Remoting debug support. |
static | trace(
obj:
Object)
: VoidSends a serializable ActionScript object as a client trace event to the NetConnection Debugger. |
| Properties | |
static | version:
String Component version. |
| Method Detail |
static
initialize(
)
: Boolean
Returns
A Boolean value that returns a value of true if debug support is successfully initialized; otherwise, it returns false.
NetDebug.initialize() method to initialize debug support before creating a gateway connection to the customerData service.
// import NetDebug class
import mx.remoting.debug.NetDebug;
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.remoting.PendingCall;
// initialize debugging support
var debug:Boolean = NetDebug.initialize();
custService = new Service(
"http://localhost:8300/flashservices/gateway",
null,
"customerData", // access customerData service
null,
null);
// call service method
var pc:PendingCall = custService.getCategories(); // get all categories
// establish result and fault handler methods
pc.responder = new RelayResponder(this, "onCategoryData", "onCategoryFault" );
You can effectively combine the steps of importing the NetDebug file and calling the NetDebug.initialize() method by specifying the full class name when you invoke the method. The constructor for the CustomerInfoForm class in the CustomerInfoExampleAPI sample application uses this technique, shown in the fourth line of the following example:
class CustomerInfoForm extends Form {
function CustomerInfoForm() {
super(); // perform superclass initialization
mx.remoting.debug.NetDebug.initialize(); // initialize the NCD
custService = new Service(
"http://localhost:8300/flashservices/gateway",
null,
"customerData",
null,
null);
// load category combo
var pc:PendingCall = custService.getCategories(); // get all categories
pc.responder = new RelayResponder(this, "onCategoryData",
"onCategoryFault" );
}
For the complete CustomerInfoExampleAPI sample application, see Using the Flash Remoting ActionScript API in the CustomerInfoExampleAPI application.
See Also
mx.remoting.Connection.getDebugConfig
mx.remoting.Connection.getDebugId
mx.remoting.Connection.setDebugId
mx.remoting.Connection.trace
mx.remoting.debug.NetDebug.trace
static
trace(
obj:
Object)
: Void
Parameters
obj:
Object - the ActionScript object that is sent to the debugger.
NetDebug.initialize() method to initialize debug support, then connects to the CustomerInfo service and, if the debug flag has a value of true, it calls the NetDebug.trace() method to display a message in the NetConnection Debugger.
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.remoting.PendingCall;
import mx.remoting.debug.NetDebug;
import mx.services.Log;
var debug:Boolean = NetDebug.initialize();
var custService = new Service("http://custinfo/flashservices/gateway", new Log(), "CustomerInfo", null, null);
custService.getService("myService", this);
if(debug)
{
NetDebug.trace({level:"testing", message:"This is the message field of an object sent the NCD via trace"});
}
See Also
mx.remoting.Connection.getDebugConfig
mx.remoting.Connection.getDebugId
mx.remoting.Connection.setDebugId
mx.remoting.Connection.trace
mx.remoting.debug.NetDebug.initialize
| Property Detail |
static
version:
String
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx2004/actionscript_api_reference/mx/remoting/debug/NetDebug.html