Debugging Techniques

As you may have noticed already, server-side ActionScript is difficult to debug. Macromedia Dreamweaver MX does not include an ActionScript interpreter like the Flash ActionScript Editor. Although it has code hinting for SSAS, it does not have the handy Code Format (or Code Cleanup) control that Flash MX has.

Testing SSAS is tricky because you may need a number of elements in place, such as multiple Flash players, Flash Remoting MX Servers, and database servers. You have to watch Flash ActionScript using Flash MX, and watch server ActionScript using the App Inspector. Trace activity happens in the App Inspector, which is a great tool; however, it requires some tricky multitasking to place it in your workflow.

Clearly, the best form of watching your script is the Live Log window of the App Inspector. This tool allows you to manually instantiate your application. The problem is that you have to create an instance before you can see the Live Log. If your script has errors in it, a warning icon will appear in the active instance window. Double-clicking that icon displays any compile error messages received by the SSAS interpreter. But watching the Live Log will give you the best idea of where the error is occurring.

A great trick to spot errors before you save your SSAS is to leverage the ActionScript interpreter inside Flash MX. When you have updated your SSAS, copy the entire script into the ActionScript panel within a new Flash document. Use the Check Syntax tool (click the checkmark at the top of the ActionScript panel or press Ctrl+T). This parses the SSAS and reports any syntactical errors. Also, use the AutoFormat tool (next to the checkmark) to format your code so it's easier to read.

When you are finished, copy everything back in to your SSAS Editor or Dreamweaver MX, save the file, and reload your application. It would be a great future feature of Dreamweaver MX to include the ActionScript interpreter in its next release (hint, hint).

One last tip is to make use of onStatus as much as you can. Trace the activities to the Live Log. There is a complete list of every information object sent by the Flash Communication Server in Appendix C,"Information Objects (Server and Client) Quick Reference."

    Part I: 10 Quick Steps for Getting Started