AS2 OOP: Class Structure
         by senocular  

Introduction
To learn classes all over again. Just when you thought you had it straight with ActionScript 1.0, Macromedia goes and does a thing like this. It's not as bad as it seems though. This new method of defining classes with ActionScript 2.0 can actually be easier than with ActionScript 1.0. That is, once you get past the fact that each class needs to exist in its own file (that can be hard to get used to). If you've already been doing this using #include, though, it may not be a big deal.

Whenever a class is defined with ActionScript 2.0, it gets its own .as (ActionScript) file. These .as files for classes can only have one class per file and need to have the same name as the class being defined within. For example, if you were defining a Plane class, its definition, including all its variables and methods, would be included in a Plane.as file. This may seem a tedious process at first, but its another step in maintaining organization and improving your coding practices. The advantages are less apparent in smaller projects. But with the bigger ones, you'll definitely see a difference.

Within these files goes the code that basically defines ActionScript 2.0. Elsewhere, such as within your main movie, you're still pretty much still dealing with ActionScript 1.0, or at least its familiar syntax. ActionScript 2.0, however, is the language for writing classes. So let's see how that works.

 

 

 




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.