【发布时间】:2010-08-21 01:37:23
【问题描述】:
我有一个名为Level 的类,它继承了MovieClip。 Level 在设计器中有一个名为 gridView 的子代,gridView 在 Level 构造函数中使用。
我还有一个名为Level1 的类,它继承了Level。当我尝试addChild(new Level1()) 之类的东西时,Level 构造函数中出现错误,说gridView 为空。我做错了什么?
部分代码:
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
【问题讨论】:
-
Level1 是否附加到创作中包含名为 gridView 的对象的 MC?如果不是,那是你的问题——类继承只发生在代码中; Level 的子类不会有自己的 gridView 实例,因为父类在创作中声明了一个。
标签: flash actionscript-3