Flash player 10 crash on Regular Expression
Posted: March 18th, 2009 | Author: erik | Filed under: Actionscript quirks | Tags: debug, expression, flash, player, regular |Problem
While working on the Tommy Hilfiger Denim website, I encountered an extremely weird error. After deploying an alpha version of our work to our staging environment, I found out that on other machines the flash player only showed a blank screen and didnt execute any code at all. I checked the lack of code-execution by trying to trace a message to FireBug. Regrettably, the Firebug console stayed empty…..
After several tests it appeared that the website was working only on browsers with the Flash 10 Debug Player and simply died instantly after initiation on browsers with the regular Flash player 10. Yes….. you’re reading this correctly. It’s exactly the opposite of what you’d expect! The app crashes on the regular player and works fine on the debug player. The debug player didn’t even display an error message!
Cause
After traversing the code line by line, the problem was found when my co-workers were complaining about all the hairs lying around. Since I start every method with a call to my Debug class (which traces/logs a message to my trace panel “Trazzle“), it’s usually very easy to see where the code breaks when you’re not in a debug environment. It appeared that within the Debug class, there was a RegEx statement that killed the entire execution of code inside the regular Flash player:
-
new Error().getStackTrace().match(/([A-Za-z\[\]\_\-:0-9\\\/\ ()\.\$])+/g);
We used this line to show stracktraces inside FireBug, but somewhere something went wrong
Solution
We didn’t find a solution for this problem, but simply removed this line of code. We weren’t using Firebug tracing anyway. If anyone knows what the problem could be, you’re welcome to let me know!
Once, I ran into some problems with RegExp, and my solution was to wrap the pattern with quotes, to make it look like a String. Yep, it sounds weird. It may not fix you problem though. It’s just 1 bit of my personal experience with RegExp which solved some serious misbehavior.