First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Kortex | Website: http://www.visualflowdesigns.com/


So to sum up here is what I want to get across (not all of these points were shown in the examples):

  • Inheritance is a linguistic level method of code reuse.
  • Subclasses (those that extend another class via the extends key word) inherit based on access modifiers set in the parent class (the one being extended).
  • Both variables and methods can be inherited.
  • In actionscript (and many other object based languages) a subclass can only extend one parent class. In other words, I can't do class Son extends Father, Grandfather where Grandfather is the name of another class. Some languages do support extending more than one class and this is referred to as multiple inheritance if you want to look into it.
  • Inheritance chaining is allowed so I could do Class Father extends GrandFather and then Class Son extends Father which would result in Father having the variables and methods of GrandFather and class Son having the variables and methods of both Grandfather and Father.
  • Multiple classes can extend the same parent class. So Class Son extends Father and Class Daughter extends Father is fine, but note that while Son and Daughter would share (as in both have) the code inherited from Father, defining a method in Daughter does not mean it appears in Son and vice versa.

So that was a very basic introduction to inheritance. Again, much more could be, and has been, said about this topic. If you want to learn more, there are always people talking about such topics in the forums.

» Level Intermediate

Added: 2007-12-10
Rating: 9 Votes: 5
» Author
Kortex (aka Jeremy Wischusen) is a Flash/PHP developer for myyearbook.com and the lead software architect for the DigitallyU Digital Portfolio Software Suite.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.