Reputation: 17820
I have a static variable named debug
that I'm trying to access in my class that is generating an error.
Access of possibly undefined property debug
The property is defined on the base class.
public class Animal {
public static var debug:Boolean;
}
public class Meerkat extends Animal {
public function Meerkat() {
trace("debug:" + debug); // error here
}
}
Can a class not access a static variable on it's super class?
Update. This is odd. It seems the error went away but there is now a warning there with the same message as the error.
Upvotes: 0
Views: 85
Reputation: 724252
That's correct. Static variables are not inherited by subclasses. This is documented here, which also suggests working around it by declaring an instance variable with the same name. Not sure how useful of a workaround that is, since you might as well change the static variable to an instance one instead of having both (unless you really need to call Animal.debug
elsewhere), but it's AS3, it's there.
Upvotes: 4