22
Annoying Flash Bug
The other day, I was doing some flash programming, and ran into this error message:
"someCodeLibrary.as" Line 13 - ActionScript 2.0 class scripts may only define class or interface constructs.
"someCodeLibrary.as" Line 15 - ActionScript 2.0 class scripts may only define class or interface constructs.
… etc.
Basically, this error message was coming up for every line of someCodeLibrary.as.
Initially, I figured it was a simple syntax error in someCodeLibrary.as that was causing cascading compile errors. But as I poked at the files, nothing seemed to jump out of me and any modifications I made were in vain.
I then considered the possibility that I was including the library incorrectly.
I checked my statement:
#include "someCodeLibrary.as"
But this was correctly formatted. I checked to see if I was including the file in the wrong place, or if I had some sort of error prior to including the file, but still, no dice.
I bashed on trying all sorts of different things before finally googling the error message to see what came up. It suggested all sorts of issues related to classes, but this file wasn’t a class. It was just a straight code import.
In frustration, I began simply eliminating whole swaths of code to try to isolate the problem to one section of my program. I noticed that when I had one section of code in, the errors were coming up for the two .as files, whereas when I did not include that section, they were only coming up for one .as file. Coupled with the fact that all the internet searches were turning up issues related to classes, I had a eureka moment and managed to track down the bug.
You see, somewhere in my code, I had accidentally left in the following line from before a refactor:
someCodeLibrary.foo()
Originally, my code was nicely organized as a bunch of classes in their respective directories. Unfortunately, the hardware I’m working with has some significant performance limitations, and I discovered that having a bunch of functions and variables declared in global space provided better performance than having them all encapsulated in a class. So I refactored the code to have someCodeLibrary be a collection of functions and variables and changed the import foo.bar.bas.someCodeLibrary command to #include "someCodeLibrary.as"
Apparently, in the process of doing this refactor, I left some calls to the now defunct class in the program. But instead of giving me a nice error message saying that said class had not be imported or that the symbols couldn’t be found, Flash decided to “helpfully” auto-import someCodeLibrary.as as a class definition, and then spit out a bunch of errors for the file when it found someCodeLibrary.as to be incorrectly formatted for a definition of a class.
Quite an annoying bug to have run into, and it really adds to the frustration I feel with Flash at times. Although I really like programming in flash, Adobe’s IDE and compiler sometimes leaves some things to be desired.
There are no comments.