Async Flash Studio Tutorial - Debug in Flex Builder

Flex Builder is a great actionscript 3 developing environment. It provides plenty of functions to help debug your actionscript code, including Call Stack,BreakPoint,Expression Watching,etc. To use the debug function of Flex Builder, A swf or html file must be launched, as show in the following dialog.

For AFS, The swf file is embeded into an execution file. which is not accepted for debugging in Flex Builder. In order to debug your actionscript code in the swf file, you need to launch your execution file by yourself. The steps to do is:

  1. First, create a Flex Builder project, a swf file will be found in bin-debug directory. Use the swf file as main swf file of AFS project. Build the output execution file.
  2. Second, in Flex Builder, open the debug properties window for you project. Modify "URL or path to launch" property: uncheck "Use defaults" checkbox, and specify the path of the built execution file as the path for debug. Click Ok button.
  3. Finally, Debug your project as Flex Application, and a flash player pops out without any content in it, and a progress bar is shown in status bar of Flex Builder. Launch your execution file by yourself now, you will see debug information appear in the console panel. and now you can debug your actionscript code, you can add breakpoint, you can see the call stack, everything works well.

The Intrinsic: The debuggers of Flex Builder communicate with the Debug Flash Player with a TCP socket, so when you debug Flex Application in Flex Builder, it creates a socket on port 7935 and listen for it. when the execution file are lauched, the flash control in it will connect to the debugger, hence the connection is established, and then you can add breakpoints, inspect variables, and do other common debugging tasks. Notice you must have debug version of flash player installed or embeded in the AFS project execution file.

See Adobe Flex 3 help for more information about debuggers of Flex.