After page upon page of confusing examples of inheritance, encapsulation, polymorphism and other oop terms, i decided to take some advice of a colleague and break it all down to the simplest parts. So I did and I think the fog is clearing a little concerning OOP.
Some tips about grasping oop:
1) Everything is an Object
2) Classes are blueprints
3) Extending a class opens up all of those methods to your new class, build on that foundation
4) An object does not exist util instantiated
5) OOP is a tool, it cannot replace procedural programming
OOP programming comes in many shades of gray, for this post lets consider that oop procedures are accomplished through the creation of Actionscript 3 class packages , hence objects. Each object is responsible for one thing, being itself.
Program for me a candle.
I would package an actionscript class called Candle . Within this actioncript file I would procedurally program the functionality of a candle. The candle should react to things just like a real one. Create a function
lightIt();You call the function the candle brightens the room. The amount of functionality is totally up to you, the "object creator". There is no limit, your candle object could react to being left in the sun or even relight like a joke birthday candle. Just be sure that you don't go to far. Make the candle as basic as possible and extend it into new child classes, like a birthday candle class that extends Candle. You can always make objects more complicated , start simple.
Now store your candle in your special package directory and call upon it any time in the future when you need an object like a candle. Build upon objects, add functionallity simply and quickly, and then interact with other objects that you have created.