NetConnection.trace( ) Method | Flash 6 |
displays a string or object in the NetConnection debugger |
Any string or ActionScript object that is serializable as a string.
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.
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( ); my_conn.trace("URL established"); var my_service = my_conn.getService("com.oreilly.frdg.searchProducts"); my_conn.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 NetConnection.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).
NetDebug.trace( ); Chapter 13