Showing posts with label wtf flash. Show all posts
Showing posts with label wtf flash. Show all posts

Wednesday, December 19, 2012

What The Hell, Flash? Ep 2: When frame action gets inherited

Here we go again.

My work flow of doing Flash animation is to tween stuff in a MovieClip and use labels + gotoAndPlay() calls to switch between animations. Nowadays, with the switch to AS3, most of the animation controls are done via external script files, so the MovieClips in my library are now mostly devoid of any frame based actionscript (a very old leftover technique from like the Flash 4 days)... except that I still use frame actions for very simple looping calls (gotoAndPlay("anim1") at the last frame of the anim1 animation frames, for example).

I guess the title of this post is a pretty big spoiler, but I'm surprised I didn't encounter this problem until now. Usually if a series of animations shares the same animation control scripts (say, guy1, guy2, and guy3 all have different animations but are handled the same way), I'd have a common class that the animations would inherit from (Guy1 extends GuyAnim, Guy2 extends GuyAnim, etc). Only this time, I got lazy... I have a few animations inheriting from the first of its archetype, which contains all the control scripts (so Guy2 now extends Guy1, and Guy3 also extends Guy1...)

Imagine my surprise when the animations start glitching like no tomorrow. I guess getting a strange "invalid function override" warning when I place frame scripts on certain frames should have warned me to something, but it's just one of those quirky things where intention don't match behavior. I have two timelines with one set of animations in one clip and another set of animations in another clip. I have two script files (that doesn't contain any of the frame script) where one inherits the other. In appearance, nothing overlaps, but somehow the frame scripts are probably attached to the class objects during compile time, and the result is a total animation glitchy mess.

There are times when actionscript can accommodate the strangest, anachronistic workflows between multiple versions of Flash and still somehow make it all work. Then other times... well, this happens. Oh Flash, how I learned to hate to love you.

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.

Bonus Art Day: Tech Support

Totally not a stereotype (it is)