I’m currently updating some as2 projects to as3 and I had a series of 1120 compiler errors this afternoon. I’m a fan of using the ‘extends’ keyword to create customised versions of base classes.
In Actionscript 2 the subclass can access all the variables and methods of the original class. It appears that in ActionScript 3, things are much stricter and only public variables and methods are accessible.
For example, this won’t work:
A.as
package
{
public class A{
private var propertyA:String = "Private Property from the A class";
public function A(){
trace("A.A()");
}
public function methodA(){
trace("---A.methodA()----");
trace("- propA:"+propertyA);
}
}
}
B.as
package
{
import A;
public class B extends A{
private var propertyB:String = "Private property from the B class";
public function B(){
trace("B.B()");
}
public function methodB(){
trace("---B.methodB()----");
trace("- propA:"+propertyA);
trace("- propB:"+propertyB);
}
}
}
The compiler error is:
1120: Access of undefined property propertyA.
But if you change the private var propertyA (in A.as) to public var propertyA, then the compiler is error free.

3 Comments
Thanks – This was a total help!
your situation (and mine as ov 5 minutes ago) can be solved by swapping “private” for “internal”. I’ve had errors with private functions, which won’t compile when I’m trying to do simple overrides, and say for example inheriting a variable. A bunch of examples I had a while back from a cookbook kept using internal. I’m no oop guru, I’m still trying to get to grips with the whole thing, so i don’t know why private fails and internal works or what their difference is
Hi Paul, Yep you’re right. I did a quick bit of research. As I understand it now the keyword internal is like private but for the entire package, not just the individual class. So that would make it usable in the above example as extended classes are in the same package.
Thanks