ActionScript 3 Class Definition and Importing Sickness

Sorry, but this post is about some programming garbage.
Okay, so i decided to write a little ActionScript 3 code since it's all object-oriented and somehow "real" compared to the previous joke versions. I was trying to create a small class that did some simple stuff and get it working in the Flash environment. After reading several examples straight from Adobe and some forums I wrote what looked like a simple, pristine piece of code that should have worked.

The error I got when I tried running the code was this:

1180: Call to a possibly 
undefined method xxxx

This basically means that Flash couldn't find the class that I created. But I didn't get any errors from the "import" statement that references the .AS file that has the class in it (inside a package{}).

If I changed the filename I'm trying to import I get an error. Ok, so it knows the file is there but it cannot find the class inside the file for some reason.

I searched all over the net for an hour trying to find the answer to this problem. NOWHERE DID I FIND THE SOLUTION THAT I AM ABOUT TO GIVE YOU. The solution to the problem is something that, evidently, Flash programmers JUST KNOW from experience but the solution isn't written anywhere that I could find on the internet and my Flash coders don't know how they know the technicality I'm about to explain.

So it comes down to this: the way you write the name of your class MUST be the EXACT way you name the .AS file it's in.

For example: if I create a class named BugJar like so:

package
{
    public class BugJar
    {
        //...code...
    }
}

then I **MUST** save it in a file named BugJar.as!!!!

Inside my framecode I would have:

import BugJar;

...and it would work.

This is just completely disgusting to me as a programmer. Linking the name of a class to the filename of the file it's in is just wrong.

What's worse is that Flash doesn't even give you the proper error for this:

filename: bugjar.as

package
{
    public class BugJar
    {
        //...code...
    }
}

framecode:

import bugjar;
var jar:BugJar = new BugJar();

The above example WILL NOT WORK and Flash doesn't give you an error message that helps you understand or fix this problem that shouldn't exist in the first place.

Previous
Previous

The Amazing Iron Man

Next
Next

Blue Oyster Cult Loves Star Blazer?