AS1 OOP: Introduction
         by senocular

Here we are going to cover Object Oriented Programming (OOP) in Flash with Actionscript 1.0. If you are familiar with Javascript, you will feel right at home as Actionscript is based on the ECMA-262 (The European Computers Manufacturers Association) specification of which Javascript is based. Actionscript 1.0 is used by Flash 5, MX and MX 2004. Though it pretty much started with Flash 5, a lot of what will be covered is specific to Actionscript in Flash MX and later. For OOP in Flash 5, see Building Object-Oriented Applications in Flash 5 by Robin Debreuil. As for MX2004 you would need to specify Actionscript 1.0 in the Publish Settings of your movie. Though Actionscript 1.0 still works in conjunction with Actionscript 2.0, some of the topics discussed will not function due to the restrictions placed on some aspects of Actionscript 1.0 when the primary language is set to Actionscript 2.0.

Where to begin when dealing with such a huge subject such as OOP in Flash Actionscript? Well first, I guess it's a good idea to cover our bases for all real programmers out there by saying, strictly speaking, Actionscript is NOT an OOP language. It lacks many qualities which are inherent to object oriented programming such as encapsulation. However, when using and referencing the term OOP with Actionscript, it's done so based on the degree to which Actionscript is capable of delivering it. So, whenever you hear or even think OOP in conjunction with Flash you should think of OOP only as OOP as Flash can be (yeah you know me!).

More Generally speaking, OOP can be seen as a method of organizing and implementing your programming in an easily handled and portable manner. Instead of focusing on functions to handle operations in your program, objects are used to contain and control information. These objects can contain not only information, but also the methods (functions) needed to control it. As such, objects are self contained an unreliant on other aspects of the program making them easier to deal with and, you guessed it, more portable when used again in other applications.

The whole ease of use and portability are probably the most outstanding benefits of OOP. Ease may not be so apparent in smaller projects (at which case OOP might not be a direction to take) though with larger projects, having separate objects to control your program's data becomes very useful. Such a design inherently yields a smoother migration when reusing code from one program to the next. In doing so, you are also able to easily adapt code, expanding on objects using inheritance (discussed later) making it much easier to reuse code more effectively with little effort; this of course, making your life as a developer, much easier to bare.

Before really getting into the thick of it all, some basics need to be covered. Be forewarned, however. The sections in this tutorial may be a little long winded. It assumes a very very basic knowledge of Actionscript so much of the information may be redundant for those who are more experienced even contradictory to your understanding. The goal is to provide the information in an easy to understand fashion. So without further ado, let's continue.



SUPPORTERS:'s fast and reliable hosting provided by Media Temple.