Hey guys,
I am hoping someone can explain about subclasses accessing variables from the super class.
I found that the subclass can only access variables which are set in the constructor of the super class. Is there any way around this?
package Character {
import flash.display.MovieClip;
public class Character extends MovieClip {
protected var test_declared_early:String = "declared early";
protected var test_declared_late:String;
private var knight:Knight;
public function Character() {
// constructor code
}
public function init(_local_stage:Object){
test_declared_late = "declared late";
knight = new Knight("matt");
}
}
I try to access the strings in the subclass, but can only get one:
package Character{
public class Knight extends Character.Character {
private var myName:String;
public function Knight(local_name:String) {
// constructor code
myName = local_name;
trace(super.test_declared_early); //this is not null
trace(super.test_declared_late); //this is null
}
}
}
My entire test project can be found here: http://www.mediafire.com/?46zwpfo4h47cdaq
Thanks!