AS1 OOP: Custom Object Classes
         by senocular  

Instances
The point of defining a custom class is to define what will ultimately be object instances of that class – the actual working object in which you use in Actionscript to contain data and/or add functionality to your movie. These instances are equivalent to the houses in the blueprint analogy. They’re the final product resulting from the deployment of the layouts provided from the blueprints of the constructor function. You can have as many instances as you want all from the same single class constructor – as many as you need to populate your Flash movie, or neighborhood if you will. Each instance created is then said to be an "instance of the class." House instances made from the House class are instances of the House class just as arrays are instances of the Array class.

Instances are really what you’re after with OOP. The idea is to develop a framework from which you would be able to create meaningful, functional, easy to work with object instances which help you get done whatever it is you need to get done in your Flash movie.

For example, arrays are instances of array objects. Arrays help you manage and handle variables and information. You use arrays because they offer a simple linear fashion of containing variables in a list. This list then has associated with it methods that let you handle this information – methods like push, shift, reverse, sort etc.. The Array class provides the ability for you to create these helpful objects. Using OOP you are then able to create your own foundation from which you are able to create your own custom instances with similar functionality, only their functionality will be as you specify and not limited to that which has been pre-defined for you in Actionscript. Then you will be able to reap the benefits of OOP.
 

Prev Page
 



SUPPORTERS:

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