我试图从外部类访问舞台,这就是我所拥有的:
Player.as(主类)
import flash.display.MovieClip;
public class Player extends MovieClip
{
private var _controls:Controls;
public function Player()
{
// constructor code
_controls = new Controls();
}
}
控件.as
import flash.display.MovieClip;
public class Controls extends MovieClip
{
private var _playbtn:MovieClip;
public function Controls()
{
trace(this.getChildByName("playbtn"));
}
}
但这条线trace(this.getChildByName("playbtn"));
总是错误我什至尝试过:
trace(stage.getChildByName("playbtn"));
trace(parent.getChildByName("playbtn"));
但我得到同样的错误:
空为此和
无法访问空对象引用的属性或方法。舞台和家长
有什么我做错了吗?