单击按钮后尝试播放声音后,Flash CS4 中出现调试错误 1046
这里是新手闪存程序员。我试图让 Flash 影片在用户单击按钮后播放导入的打孔声音。我收到此错误:“1046:未找到类型或不是编译时常量:punch。”
这是代码:
stop();
var punch:punch = new punch();
btn2.addEventListener(MouseEvent.CLICK, playSound2);
function playSound2(e:MouseEvent):void
{
punch.play();
}
更改“varpunch:punch=newpunch();”到“varpunchSound:punch=newpunch();”解决了我的问题,但我想知道为什么“varpunch:punch=newpunch();”没用?
提前致谢
Noobie flash programmer here. I am trying to get the flash movie to play an imported punch sound after the user clicks a button. I got this error: "1046: Type was not found or was not a compile-time constant: punch."
here is the code:
stop();
var punch:punch = new punch();
btn2.addEventListener(MouseEvent.CLICK, playSound2);
function playSound2(e:MouseEvent):void
{
punch.play();
}
changing "var punch:punch = new punch();" to "var punchSound:punch = new punch();" solved my problem but I was wondering why "var punch:punch = new punch();" didn't work?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要导入打孔类
varpunch:punch 不起作用的原因是因为 var 和类不能具有相同的名称。
按照标准,类名的第一个字母应该大写,因此如果您有一个名为 Punch 的类,则以下内容将起作用
you need to import the punch class
and the reason why var punch:punch did not work is because you can not have a var and a class named the same.
by standards the first letter of a class name should be capital so the following would work if you had a claass named Punch