Soundmanager:MySound 未定义
soundManager.url = 'swf/';
soundManager.createSound({
id: 'mySound',
url: 'http://localhost/htmlshooter/mp3/gun.mp3',
autoLoad: true,
autoPlay: true,
volume: 100
});
function placeimage(){
var t = $('<img src="img/php/target.png" alt="image" id="' + Math.floor(Math.random()*55) + '" onclick="doclickimg(this.id);">');
$('#div').append(t);
t.css('left', Math.floor(Math.random()*(800 - t.width())));
t.css('top', Math.floor(Math.random()*(300 - t.height())));
setTimeout(placeimage, 2000);
}
placeimage();
function doclickimg(imgid){
doclickdiv();
$('#'+imgid).remove();
// +1 score
}
function doclickdiv() {
mySound.play();
// -1 bullet
}
现在,当我单击我的 div 时,图像不会消失,并且它表示未定义来自 doclickdiv() 中的 MySound.play 的 MySound。
请帮我!为什么这不起作用?
soundManager.url = 'swf/';
soundManager.createSound({
id: 'mySound',
url: 'http://localhost/htmlshooter/mp3/gun.mp3',
autoLoad: true,
autoPlay: true,
volume: 100
});
function placeimage(){
var t = $('<img src="img/php/target.png" alt="image" id="' + Math.floor(Math.random()*55) + '" onclick="doclickimg(this.id);">');
$('#div').append(t);
t.css('left', Math.floor(Math.random()*(800 - t.width())));
t.css('top', Math.floor(Math.random()*(300 - t.height())));
setTimeout(placeimage, 2000);
}
placeimage();
function doclickimg(imgid){
doclickdiv();
$('#'+imgid).remove();
// +1 score
}
function doclickdiv() {
mySound.play();
// -1 bullet
}
Now when i click on my div, the image won't disappear, and it says that MySound, from MySound.play in doclickdiv() isn't defined.
Please help me! Why isn't this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到此错误是因为
mySound
尚未定义对象。你可能会有更好的运气……或者……
You are receiving this error because
mySound
isn't a defined object yet. You'll probably have better luck with...or...
mySound
未定义。您可能想要更改:
mySound
is not defined. You probably want to change:to