我有一個名爲Level
的類,它繼承MovieClip
。 Level
有一個名爲gridView
的設計師的小孩,gridView
用於Level
的構造函數。
我也有類名爲Level1
繼承Level
。當我嘗試類似addChild(new Level1())
時,我在Level
構造函數中遇到錯誤,說gridView
爲空。我究竟做錯了什麼?閃存中的MovieClip繼承錯誤
的代碼的某些部分:
public class Level extends MovieClip
{
public function Level()
{
var matrix:Matrix = new Matrix();
matrix.translate(-250, -250);
matrix.rotate(Math.PI/6);
matrix.scale(1, 0.5);
matrix.translate(250, 250);
gridView.transform.matrix = matrix; // error here referred from:
}
}
public class Level1 extends Level
{
public function Level1()
{
super();
}
}
addChild(new Level1()); // referred from here
addChild(new Level()); // this worked fine
在包含名爲gridView的對象的創作中,Level1是否連接到MC?如果不是,那就是你的問題 - 類繼承只發生在代碼中; Level的子類不會因爲父類在創作中聲明瞭一個而沒有自己的GridView實例。 – fenomas 2010-08-22 16:04:09