Name

NetDebug.trace( ) Method

Synopsis

NetDebug.trace(string_or_object)

Arguments

string_or_object

Any string or ActionScript object that is serializable as a string.

Description

The trace( ) method is used during debugging to display a string, object, or other value in the NetConnection Debugger panel. This is useful during debugging for determining where a particular problem might be occurring.

The NetDebug.as file must be included in order to use the trace( ) method, and the NetConnection Debugger panel must be open as well.

Example

The following code shows the basic syntax of the trace( ) method:

#include "NetServices.as"
#include "NetDebug.as"

if (connected == null) {
  connected = true;
  NetServices.setDefaultGatewayUrl("http://127.0.0.1/flashservices/gateway");
  var my_conn = NetServices.createGatewayConnection( );
  NetDebug.trace("URL established");
  var my_service = my_conn.getService("com.oreilly.frdg.searchProducts");
  NetDebug.trace("Service object created");
}

The trace( ) statements in this block of code merely alert the developer that a specific line in the code was reached. This is helpful for narrowing down problems in blocks of code. The output of the NetDebug.trace( ) method is sent to the NetConnection debugger (don’t confuse it with the global trace( ) function, which displays text in the Flash authoring tool’s Output window).

See Also

NetConnection.trace( ), the NetDebugConfig class; Chapter 13

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.