Using the NetConnection Debugger

The Netconnection Debugger (NCD) is the most important tool you have for debugging Flash Remoting applications. It gives you the ability to see the Remote calls responses that your application makes, as well as error messages, and user-defined defined messages. It is useful for testing applications running both inside and outside the Flash authoring environment.

If you’ve already downloaded and installed the Remoting components from Macromedia, the NCD can be activated by going to Window > NetConnection Debugger in Flash’s main menu. It is recommended however that you run the NCD outside of Flash. This can be done by double-clicking the NetConnection debugger.swf file in your configuration folder, as outlined in Installing Remoting.

Make sure the NetConnection debugger classes are included in your Flash file (Window > Libraries > Remoting). Enable the NetConnection debugger like so:

import mx.remoting.debug.NetDebug;
NetDebug.initialize();  // initialize NCD

INow, when your application makes a remoting call, you’ll see something like this:

When your application is ready to go live, you can comment out the NetDebug.initialize() call and you’ll remove the ability to use the NCD to view the details of the Flash Remoting communications.

Remember that if you see sensitive info in the NetConnection debugger, then disabling it will not stop anyone with a decompiler and the right skills to unhide it. Thus, don't send sensitive info over the wire. In particular, if you select users from a table, don't select the password column and return it (you'd be surprised how many do this with all forms of Remoting).

General Usage

The NCD shows the remoting calls that the application makes, and it also shows the results. If your call is exactly what you think it should be, and the result isn’t what you’d expect, then you’ve probably got a problem in your code on the server-side. Often (though not always) if there is an error in your PHP, it will also show up in the NCD. One of the most common errors is the NetConnection.Call.BadVersion error. In general, any unexpected results in the NCD indicate a problem on the server-side.

The NCD is a tool that you open from the authoring environment, but it can also intercept AMF data from SWFs running elsewhere, like in a browser. This can be extremely useful for debugging applications as they run in the browser, which is usually their intended environment. For those who are used to debugging with the trace() function, and cursing that it doesn’t work outside of the authoring environment, the NCD’s NetDebug.trace() will be a welcome improvement.

NetDebug.trace

With NetDebug.trace(), you can send output to the NCD. It’s a bit more sophisticated than the standard trace() that you might be used to. It can trace out different kinds of objects automatically, rather than just strings. Both of these usages are valid:

NetDebug.trace("Hello world");
NetDebug.trace(myObject);

This is a highly valuable function that you can insert in your code at various places to ensure that certain variables are as you expect them to be (NetDebug.trace(“x was: ” + x);), or just to ensure that you got to a specific point in your code (NetDebug.trace(“Notice: function doSomething() was called.”);).


© amfphp.org | Disclaimer | Conditions of use