First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
Search tutorials
Author: Kortex | Website: http://www.visualflowdesigns.com/

Summary

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
(10 being the highest)
» 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.