OOP, constructors. Why is the object null?
Hi. Here's AS3 behavior that I don't quite understand. The code is:
public class TestA
{
public var data:Object;
public function TestA()
{
trace("From A", this.data);
}
}
public class TestB extends TestA
{
public function TestB()
{
//this.data = { test: 5 };
this.data = new Object();
trace("From B", this.data);
super();
}
}
import flash.display.Sprite;
public class TestApp extends Sprite
{
public function TestApp()
{
var t:TestB = new TestB();
}
}
This outputs
From B [object Object]
From A null
where I would expect
From B [object Object]
From A [object Object]
How come?
Using Flex 4 SDK with FlashDevelop.
