[英]Error 1046 in AS3. 3 simple buttons, nothing works?
I'm trying to make a simple start up screen for a game i'm making, and I put a button (Backbtn)on Frame 2, to go back to frame 1, but nothing works, it just flies through the frames, the Stop(); 我正在尝试为正在制作的游戏制作一个简单的启动屏幕,然后在第2帧上放一个按钮(Backbtn),回到第1帧,但没有任何效果,它只是在这些帧之间飞来飞去,停止(); doesn't work, and I keep getting error 1046: Type was not found or was not a compile-time constant: Backbtn. 不起作用,并且不断出现错误1046:找不到类型或不是编译时常量:Backbtn。
Any help, this is my code! 任何帮助,这是我的代码!
import flash.events.MouseEvent;
stop();
HTP.addEventListener(MouseEvent.CLICK, goClick);
PlayButton.addEventListener(MouseEvent.CLICK, goPlay);
Backbtn.addEventListener(MouseEvent.CLICK, goBack);
function goClick(event:MouseEvent): void
{
trace("two");
gotoAndStop(2);
}
function goPlay(event:MouseEvent): void
{
trace("three");
gotoAndStop(3);
}
function goBack(event:MouseEvent) : void
{
trace("TEST");
gotoAndStop(1);
}
Thank you! 谢谢!
BackBtn isn't defined until frame 2, therefore it is undefined until frame 2. BackBtn直到第2帧才定义,因此直到第2帧才定义 。
Change your code to: 将您的代码更改为:
import flash.events.MouseEvent;
stop();
HTP.addEventListener(MouseEvent.CLICK, goClick);
PlayButton.addEventListener(MouseEvent.CLICK, goPlay);
function goClick(event:MouseEvent): void
{
trace("two");
gotoAndStop(2);
}
function goPlay(event:MouseEvent): void
{
trace("three");
gotoAndStop(3);
}
And put this code on frame 2: 并将此代码放在第2帧:
Backbtn.addEventListener(MouseEvent.CLICK, goBack);
function goBack(event:MouseEvent) : void
{
trace("TEST");
gotoAndStop(1);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.