Skip to main content
Adrien_
Known Participant
August 19, 2011
Answered

Extending classes with private methods?

  • August 19, 2011
  • 2 replies
  • 694 views

my understanding of extending classes is that you gain all the functions and methods of that class thus You could over ride any one of them. How ever I am confused on weather or not you inherit and can over ride private methods of the class you are extending or if you have to have all methods public in an extended class.

hope that makes sense, an example can bee seen bellow.

package

{

     public class Class1

     {

          public function apples():void

          {

               //some code

          }

          private fnctuin bananas():void

          {

               //more code

          }

     }

}

package

{

     public class Class2 extends Class 1

     {

          override public function apples():void

          {

               //i changed code

          }

          //can I over ride bananas?

     }

}

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

Use "protected" for functions that can be overridden by subclasses.

2 replies

Kenneth KawamotoCommunity ExpertCorrect answer
Community Expert
August 19, 2011

Use "protected" for functions that can be overridden by subclasses.

kglad
Community Expert
Community Expert
August 19, 2011

you can only override methods that would be inherited.  a private method won't be inherited:

http://www.kirupa.com/forum/showthread.php?223798-ActionScript-3-Tip-of-the-Day/page5