FlashBuilder for mobile release build crash fix

Ahh – this is something that I have only just come across for mobile development via Air.
Basically everything will work fine on a debug build both in the simulator and on the device (in debug mode). Then just when you are comfortable you compile a release version and somewhere in your app bang crash wallop it all stops. Thanks to the fact its not a debug version you can only rely on a global uncaught error handler to point you in the right direction:

loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);

private function uncaughtErrorHandler(e:UncaughtErrorEvent):void
trace(“Global error:” + e);

…but that only gets you part way there – and points to some Error #1009 – the old cannot access a property error or worse a VerifyError #1024. As this post will attest to I am not the only one who has had this problem.

So the culprit you ask? Well for two of my projects it seems that Flashbuilder for some reason unknown to me will forget to strip out trace() statements meaning that they will eventually crash the app when you try to trace a test value. So the easy fix (which guaranteed will save you hours if you get this issue) – just add this line to your Actionscript compiler arguments:


That simple line of code will make sure Flashbuilder doesn’t compile the trace statements, but then why should it in the first place? Adobe really you should be ashamed…