The NetDebug.as file is not a required part of Flash Remoting, but it is required if you want to use the NetConnection debugger. The file can be included in your movie during debugging but should be removed from the code before deployment, as it adds considerable weight to the final movie.
If your application is complex, you can include a dummy MyDebugFile.as file in each of your .fla files as follows:
This dummy MyDebugFile.as file should contain one line:
// #include "NetDebug.as"
If the line is commented out (as indicated by the prepended slashes), the NetDebug.as file is not included. If you uncomment the line, the NetDebug.as file is included. This technique circumvents the lack of a conditional #include in ActionScript. It makes it easier to activate and deactivate NetConnection debugging in a single place, without the need to edit multiple .fla files.
By including the NetDebug.as file, you are also including the following files:
These files form the code base for the NetConnection debugger and the NetDebug class that you can utilize for debugging.
The NetDebug class exposes these methods, which can be called from an instance of the NetConnection object:
Displays an object to the NetConnection Debugger panel. This can be any ActionScript object.
Gets the configuration object of NetDebug (NetDebugConfig).
Gets the debugging identifier of the NetConnection object. This is an arbitrary number that can be changed by the developer.
Set the internal debug ID of the NetConnection object, which can be useful for debugging multiple connections
The methods are called from the local connection object you've defined:
NetServices.setDefaultGatewayURL(myURL); var my_conn = NetServices.createGatewayConnection( ); var myService = myConnection_conn.getService(servicePath); my_conn.trace(my_conn.getDebugConfig( ));
In the last line, the NetConnection.trace( ) method is being used to trace (i.e., display the contents of) the NetDebugConfig object to the NetConnection debugger. The output looks something like Figure 13-6.