This could be a short post: Just don’t introduce any bugs to your code, then you won’t ever have to debug. Clearly, that’s easier said than done. But seriously, how do bugs come into this world? I might address this philosophical question in a different post if there is any interest. Today I will assume that developers are not perfect beings and occasionally make mistakes, which don’t get caught by the tools they use. That’s why they have to debug their code. So how do you debug cross-compiled ActionScript?
Optimized versus Unoptimized Code
This might be obvious, but if you can, try to debug your unoptimized code. If your bug only occurs in the optimized version use Closure compiler’s -formatting=PRETTY_PRINT option, which generates somewhat readable optimized code. If that doesn’t help, use Closure’s -create-source-map option and their Closure Compiler Inspector. In very rare cases all of those methods don’t work and all that’s left is “printf-debugging”, which translates to “console.info-debugging” in the browser world.
Debugging with the Browser
At this point I always debug my cross-compiled ActionScript directly in the browser, mostly Safari on OSX. Sometimes I switch browsers depending on the task at hand.
In these days every modern browser comes with a built-in debugger that allows source-level debugging and an interactive console. I have noticed that Safari and Chrome both have difficulties when you jump out of the last expression in a function (tail calls). The debugger seems to get confused and does not stop at that last expression and jumps out to the parent scope. Microsoft’s IE10 does not have that problem. If you have to debug, i.e. jQuery’s library code you might want to switch to IE10. It will probably save you a lot of time.
Debugging with Flash Builder
So here would be my rough idea how you could implement source-level debugging for Flash Builder…
Frankly, I wouldn’t do all that work just to be able to debug from within Flash Builder. This might turn out to be a feature that requires one or more full-time developers.