Thursday, August 9, 2012

What The Hell, Flash? Ep 1: When String is an Integer, all hell broke loose

There are times when Flash is amazing to you. Things that you thought it's going to screw up, the interpreter would compensate and everything works better than you imagined. Then there's time when one wrong turn and the whole damn thing explodes.

I've been working with Adobe Flash since Flash 4, back when it was called Macromedia Flash. Every iteration since 4 has had its perks and quirks - and as a Flash dev, you learn to live with all of its idiosyncrasies and work around stuff that's actually broken.

One of the many regrets that I have over the past 10 years is that I have not been documenting all the quirky broken stuff that happens with flash - things that I tend to forget after a while and come back to bite me later. Today, I present to you this gem:


Alright, I admit that I was being lazy - I used FlashDevelop's code generation to create the constant, which automatically declares it as a string with the same name as the variable. I didn't quite erase the type definition far enough and after wrapping up other sections of the code, I compile and run and...

Blank screen.

I wondered if there's some problems with my resource loading - so I put some debug traces in the document class, compile... blank screen.

Okay, this is getting stupid. I try to launch the file in Flash's debug mode, and it says "you cannot debug this swf because it does not contain actionscript". Right. A few thousand lines of code, they just all conveniently disappeared. The source files are all there, the linkages are there, Flash just refuses to recognize I'm publishing a file that contains any code at all.

Alright, panic time, I pulled out the most recent backup of the project, retrace the changes line by line... and finally, I found this little gem that should have been caught as an innocent syntax error. Well, that's a whole day wasted, whoop-dee-doo.

Lesson of the day: Don't assign types to constants. It'll destroy ActionScript's space-time continuum apparently.

No comments:

Post a Comment

Bonus Art Day: Tech Support

Totally not a stereotype (it is)