At 1/23/15 06:43 PM, Barzona wrote:
I can't believe how long I went without using superclasses with their polymorphism. I mean, I used base classes when I created linkage for my movie clips, but I never made a class to extend to before. This is going to make everything so much easier!
I know I'm way behind all of you guys in terms of skill... I've been teaching myself for a year now (give or take a few weeks) and I just figured out how to extend classes. For example making an enemy class that stores things like hp and behavior and then having my different types of monsters extend that enemy class. Using override functions is neat too.
I feel like I'm actually learning.
Love that feeling :)
I wonder if I'll ever need to bother with interfaces. I don't really understand them, yet.
Never heard of interfaces before....I will have to look into them....
One thing I don't really understand is the use of the word "super". Can anyone explain it better to me than what I've read online?
Would it work like this with my example of enemy and monster classes that I just talked about:
// inside public class Enemy extends MovieClip
function someFunction():void
{
// do stuff
}
// inside public class Monster extends Enemy
super.someFunction(); //calls the someFunction in the enemy class
Is that how you use the super keyword? If so, is it just so you don't have to declare the Enemy class inside of the Monster class to access it?