Sunday 10 July 2011

Remote Debugging in FlashBuilder

Disclaimer: There may be a better way to achieve this goal, but this trick has served me well for many years.

Occasionally the need to debug a Flex application that has not been launched from FlashBuilder arises: the application may be present in a UAT environment or it might need to be tested outside of the security-sandbox-free-zone.. In any case, you may not be able to launch it by simply clicking the "Debug" button on FlashBuilder's toolbar.

A workaround to this problem involves creating another debug profile for the application, by either selecting the "Run -> Debug Configurations..." menu item, or clicking the down arrow to the right of the "Debug" toolbar button and selecting "Debug Configurations..." In this screen, you should right-click on the configuration of the application of note, and select "Duplicate." The duplicated item will appear with a name like, "SampleApplication (1)." Select this debug profile in the tree, and then change the "URL or path to launch" configuration as follows:

  1. Untick the "Use default" checkbox.
  2. Enter "about:blank" as the URL.
Save your configuration by clicking the "Close" button, or launch it by clicking the "Debug" button.

The idea here is that when you launch this new debug profile, the browser associated with FlashBuilder will not open a page containing the Flex application, and thus a debug connection will not be established. However, FlashBuilder will still open up a debug listening service that will wait a short time before terminating. During this time, it is possible to manually load the application to be tested. As the application loads, it should connect to the debug session waiting within FlashBuilder, permitting the usual debug operation.

4 comments:

  1. In some cases, if you are working on domains that you've mapped localy, make sure to launch your dummy page (make a blank html page) from the same domain as the app you want to debug.

    ReplyDelete
  2. Hi
    Thanks for the tip
    I'm able to see traces in the console
    but line debugging and break-points doesn't seem to work
    any idea on how to fix that?

    ReplyDelete
  3. Thanks Tim, exactly what I needed! Thanks for sharing

    ReplyDelete