PDA

View Full Version : Quick Doubt About private methods in Actionscript


vikramjparekh
05-27-2005, 03:18 PM
I am actually a beginner and am testing an Actionscript Package. I have a small doubt. Here is my situation.

I have a class lets say Class A which is as follows


Class A {

private var1:Number;
private var2:Number;


private function functionofA ():Number {

return var1;

}


}




Class B extends A {

public function functionofB ():Number {

return var1;

}



}


If I make an object of B lets say..... objectB

then if I access the variable var1....

in the following ways:-

1) objectB.functionofB() the value is returned

2) objectB.functionofA() the values is undefined (thats what is said by the trace method)


So, can I not access the private methods of the superclass in ACtionscript??? If not, then how do I access it? I cannot change the code as it is the code give to me for testing..

madgett
05-27-2005, 05:51 PM
You can't access private methods directly on an instance of a class anyways...that defeats the purpose of private methods, you can only access it within the class.

Add functionofC():
public function functionofC():Number {
return functionofA();
}
objectB.functionofC(); returns functionofA