在我必须为大学制作的一个小游戏中,我在运行时渲染一个菜单,使用我在插画器中绘制的按钮制作的电影剪辑。我像往常一样在Flash Professional中导入了插画器文件,并像处理其他运行良好的电影剪辑一样进行了AS链接。但是当我尝试呈现这些按钮时,我收到错误 1009,一个空引用。顺便说一下,我使用 AS3。
private function initMenuComponents():void{
var btnPlay:MovieClip = new Play();
var btnOptions:MovieClip = new Options();
var btnLikeOnFacebook:MovieClip = new LikeOnFacebook();
var btnShareOnFacebook:MovieClip = new ShareOnFacebook();
btnPlay.x = (stage.stageWidth / 2) - (btnPlay.width / 2);
btnOptions.x = (stage.stageWidth / 2) - (btnOptions.width / 2);
btnLikeOnFacebook.x = (stage.stageWidth / 2) - (btnLikeOnFacebook.width / 2);
btnShareOnFacebook.x = (stage.stageWidth / 2) - (btnShareOnFacebook.width / 2);
btnPlay.y = 100;
btnOptions.y = 150;
btnLikeOnFacebook.y = 200;
btnShareOnFacebook.y = 250;
stage.addChild(btnPlay);
stage.addChild(btnOptions);
stage.addChild(btnLikeOnFacebook);
stage.addChild(btnShareOnFacebook);
}
听起来您没有正确链接 IDE 中的文件。您看到的错误源于此问题。我会注释掉几乎所有的代码,并进行测试以准确找到错误所在。
var btnPlay:MovieClip = new Play();
//var btnOptions:MovieClip = new Options();
//var btnLikeOnFacebook:MovieClip = new LikeOnFacebook();
//var btnShareOnFacebook:MovieClip = new ShareOnFacebook();