Debugging Flash Remoting within Macromedia Flash MX applications
When developing rich client applications using Macromedia Flash MX, debug Macromedia Flash Remoting as you go. Common functions that you'll debug include:
- The connection to the Service Object
For example, a web service or a JavaBean. - The connection to the Service Function
For example, connecting to a method in a JavaBean or a web service. - The returned data
This TechNote describes how to use the Macromedia Flash MX NetConnection Debugger and the NetServices trace() method to debug Flash Remoting in the Macromedia Flash MX authoring environment.
The NetConnection Debugger
Use the NetConnection Debugger (NCD) to view, interact with and filter events within a movie in order to isolate problems during development. The NCD is included when you install the Flash Remoting Components but you'll need to enable it and run it within each movie.
Enabling NCD
Before using the NCD with a movie, enable it by including the NetDebug.as class file at the movie's frame level:
- Open the movie's ActionScript.
- Insert the following at the top of the ActionScript:
#include "NetDebug.as"
Running a movie with the NCD
Once the NCD is enabled for a movie, you're ready for debugging:
- With your movie open in Macromedia Flash MX, select
Window > NetConnection Debugger. - With the NCD in the frontmost window, press the CTRL + ENTER keys to run your movie.
The example below shows the NCD for a particular movie:
Debug Event pane: Displays events as they occur. When a Service Object or Service Function is called in your movie, the events display in this pane. If a function calls a Service Function when a button is clicked or released, the information displays after that event occurs in the Debug Event pane.
Clear Event button: Use this button to clear the Debug Event pane.
Summary pane: Select an event within the Debug Event pane to display its associated values within this pane. For example, the NCD window above shows a query being returned. Because it's selected in the Debug Event pane, the query data displays in the Summary pane.
Help button: Use this button to get information about how to use the NCD.
Filters pane button: Use this pane to filter out client-side and server-side events from displaying in the NCD. Filters are useful when trying to isolate a problem that is appearing in specific events.
Preferences pane button: Use this pane to select settings for the NCD. For performance reasons the NCD allows you to control the amount of resources used. The default event memory limit is 500 kb with 25 events. Increase these values if your events are truncated.
Using the trace method
The trace() method is a quick way to to see what's happening during certain events in your code. You can pass any variable to the trace() method. For example, you can use it to dynamically store a query's record count.
Enter the trace() method directly in ActionScript. When you run a movie that includes the trace() method, the Macromedia Flash MX Output window displays trace information. Because the trace() method is a NetServices method, you don't need to include the NetDebug.as class in a movie's ActionScript to use it.
The trace() method in the ActionScript below is being used to debug three different events:
if (isGatewayOpen == null) { // do this code only once isGatewayOpen = true; trace("isGatewayOpen has been set to true"); var myURL = "http://127.0.0.1:8500/flashservices/gateway"; NetServices.setDefaultGatewayUrl(myURL); trace("setDefaultGatewayURL = " + myURL); gatewayConnnection = NetServices.createGatewayConnection(); parkService = gatewayConnnection.getService ("flashremoting.NationalPark.cfc.ParkService",this); trace("parkService has been connected"); }
When this movie runs, the Output pane displays the following:
Additional information
See the Macromedia Flash Remoting Release Notes to learn more about features and functionality.
Last updated: | August 16, 2002 |
---|---|
Created: | July 3, 2002 |