【发布时间】:2012-08-05 02:09:18
【问题描述】:
我第一次开始使用 Flash CS6 来尝试为 UDK 制作 Scaleform UI。我正在学习这个简单的教程:http://goo.gl/yedMU。我已经按照信函进行了操作,但似乎无法使其正常工作。我什至在一个新项目中再次尝试过,但最终还是出现了同样的错误。我已经三次检查了每个名称和实例,但它只是拒绝工作。这是文件中两个框架的真正简单代码:
import flash.events.MouseEvent;
import flash.system.fscommand;
import flash.display.MovieClip;
subMenu_btn.addEventListener(MouseEvent.CLICK, subMenu);
exit_btn.addEventListener(MouseEvent.CLICK, exitGame);
var cursor:cursor_mc = new cursor_mc();
addChild(cursor);
cursor.x = mouseX;
cursor.y = mouseY;
cursor.startDrag();
stop();
function subMenu(event:MouseEvent):void
{
gotoAndStop('Sub Menu');
}
function exitGame(event:MouseEvent):void
{
fscommand('ExitGame');
}
和
play_btn.addEventListener(MouseEvent.CLICK, playGame);
back_btn.addEventListener(MouseEvent.CLICK, backBtn);
function playGame(event:MouseEvent):void
{
fscommand('PlayMap');
}
function backBtn(event:MouseEvent):void
{
gotoAndStop('Main Menu');
}
我使用了调试器,代码中断了
exit_btn.addEventListener(MouseEvent.CLICK, exitGame);
有什么想法吗?整个过程一直有效,直到我使用“返回”按钮返回第一帧,当“退出”按钮消失并且我收到该错误时。但是,“子菜单”按钮仍然存在,并且菜单仍然可以操作。
这是使用调试器的错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Menu_fla::MainTimeline/frame1()[Menu_fla.MainTimeline::frame1:6]
at flash.display::MovieClip/gotoAndStop()
at Menu_fla::MainTimeline/backBtn()[Menu_fla.MainTimeline::frame2:10]
【问题讨论】:
-
“主菜单”框架上是否有“exit_btn”?您是在告诉 Flash 监听不存在的内容。右侧有一个侧边栏,里面有和你有同样问题的人,你可能想看看。
-
我浏览了这些帖子中的每一篇,但没有找到答案。这是项目,您可以看到它:sendspace.com/file/f8y82w
-
我相信正在发生的事情是,每次您更改帧时,Flash 都会
NULLing 出所有的影片剪辑;如果您调试并查看此-> exit_btn(其值为空),您可以看到这一点。我将在答案部分发布我的建议。
标签: actionscript-3 flash flash-cs6