I'm experimenting with TextArea and inheritance to implement some additional functionality on the protected textField
property.
Unfortunately, when I create a new instance of the subclass, this property is set to null
. I'm probably misunderstanding the way super()
works, but I thought it would have been instantiated after the constructor finished.
Here's a small snippet of code which extends TextArea
:
public final class ExtTextArea extends TextArea {
public function ExtTextArea() {
super();
}
public function testTextField():void {
if (textField == null)
Alert.show("null!");
}
}
}
The invoking code is simple:
var extTextArea:ExtTextArea = new ExtTextArea();
extTextArea.testTextField();
The Alert
in ExtTestArea
appears every time I run this code.
Why is this? Is there something more I need to do to access the textField
property?