Everything we have done so far has been what is known as 'composition'. This name should suggest composing an object from smaller components, not a homework assignment in high school. You likely already use composition in your programs, but lets define exactly what it is to keep it from blurring later. It is often referred to as a 'has-a' relation as mentioned earlier. Object A has-an object B. A house has-a kitchen, a dog has-a tail, a rebel has-a cause. You might be hard pressed to think of an object that doesn't have-a something or other in it - everything is made of something after all. Or is it? What about ideas? For example, how does an appliance relate to a fridge? How does a monkey wrench relate to wrenches, or tools? How does James Dean relate to Ronald Reagan? to Elvis? to Che Guverra? You can see that once you start organizing ideas and concepts, has-a relations are not going to cut it alone. The tool needed for the job is inheritance - 'is-a' relationships.
Before going further, let's get used to the two ideas. Has-a relations are when one object contains another. A car has-an engine. An engine has-some pistons. Pistons have, uhh, this little black ring thing that goes around them, I think (sorry, that is the limit of my car knowledge!). Is-a relations are when one thing is a type of another thing. So a car is-a vehicle, a vehicle is-a machine, a machine is-a man-made tool with whirring parts that do stuff... (sorry again!). You really should stop now and try to think of a few inheritance systems. Obviously you didn't stop, so here's some detail.
Inheritance is not complicated, but it is hard to visualize. There is nothing in the 'real' world seems to have exactly the same behavior. This is because inheritance is more of a mental categorization system. It's easy to spot a mammal when you talk to one, but there is no such animal as 'mammal', only types of mammals. It doesn't mean the word mammal is useless of course, just don't expect the zoo to have a cage that says 'mammal'. Before we talked about objects as boxes, or containers of some sort. This works well for composition, where you put objects inside other objects, but it breaks down somewhat when dealing with inheritance. We will need to find a slightly different model to 'visualize' inheritance.
We are ahead of ourselves. Let's just make sure we are clear on the difference between has-a and is-a relations between objects (at least the easy ones). Go through the list below and decide if the relation is inheritance or composition. Try to figure out what is common in all inheritance examples, and what is common to all composition examples:
Let's go over these in (not too painstaking) detail.
Inheritance, and OO programming in general, becomes most useful when you get enough similar classes that they start to somewhat naturally organize themselves (always good to be hopeful!). This is worth mentioning, because many Flash programs are quite simple and not all that big, and have short life spans (nor is the programming even the central focus of many files). It would be overkill to use multiple levels of inheritance to link buttons to pages. Writing small programs is a bit like being the post-master in a small village. You need nothing more than the name of a person to get your mail delivered. If there is a change - someone new moves into town, someone changes houses, even a street name change - you can just keep track of it in your head. You might even laugh at how seriously big city postmasters take obscure rules, or how they debate for hours tiny changes in the postal codes. This is all fair enough; you both get the mail delivered. As long as you recognize that the village system would not work in the city, there is nothing wrong with being 'quick and dirty' when it meets all the requirements - it's probably advisable in fact. You don't want to subdivide mammals>dogs down to atoms, after all. One of the main skill sets in OO programming is finding the right balance between complexity and completeness (the same dilemma a writer faces when writing a short chapter about object-oriented programming in actionscript in fact!).