Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Soundmanager:未定义MySound soundManager.url='swf/'; soundManager.createSound({ id:'我的声音', 网址:'http://localhost/htmlshooter/mp3/gun.mp3', 自动加载:对, 自动播放:对, 数量:100 }); 函数placeimage(){ 变量t=$(''); $('#div')。追加(t); t、 css('left',Math.floor(Math.random()*(800-t.width())); t、 css('top',Math.floor(Math.random()*(300-t.height())); 设置超时(placeimage,2000); } placeimage(); 函数doclickimg(imgid){ doclickdiv(); $('#'+imgid).remove(); //+1分 } 函数doclickdiv(){ mySound.play(); //-1颗子弹 }_Javascript_Jquery_Soundmanager2 - Fatal编程技术网

Javascript Soundmanager:未定义MySound soundManager.url='swf/'; soundManager.createSound({ id:'我的声音', 网址:'http://localhost/htmlshooter/mp3/gun.mp3', 自动加载:对, 自动播放:对, 数量:100 }); 函数placeimage(){ 变量t=$(''); $('#div')。追加(t); t、 css('left',Math.floor(Math.random()*(800-t.width())); t、 css('top',Math.floor(Math.random()*(300-t.height())); 设置超时(placeimage,2000); } placeimage(); 函数doclickimg(imgid){ doclickdiv(); $('#'+imgid).remove(); //+1分 } 函数doclickdiv(){ mySound.play(); //-1颗子弹 }

Javascript Soundmanager:未定义MySound soundManager.url='swf/'; soundManager.createSound({ id:'我的声音', 网址:'http://localhost/htmlshooter/mp3/gun.mp3', 自动加载:对, 自动播放:对, 数量:100 }); 函数placeimage(){ 变量t=$(''); $('#div')。追加(t); t、 css('left',Math.floor(Math.random()*(800-t.width())); t、 css('top',Math.floor(Math.random()*(300-t.height())); 设置超时(placeimage,2000); } placeimage(); 函数doclickimg(imgid){ doclickdiv(); $('#'+imgid).remove(); //+1分 } 函数doclickdiv(){ mySound.play(); //-1颗子弹 },javascript,jquery,soundmanager2,Javascript,Jquery,Soundmanager2,现在,当我单击我的div时,图像不会消失,它说没有定义doclickdiv()中MySound.play中的MySound 请帮帮我!为什么这不起作用 您收到此错误是因为myound尚未定义对象。你可能会有更好的运气与 soundManager.url = 'swf/'; soundManager.createSound({ id: 'mySound', url: 'http://l

现在,当我单击我的div时,图像不会消失,它说没有定义doclickdiv()中MySound.play中的MySound


请帮帮我!为什么这不起作用

您收到此错误是因为
myound
尚未定义对象。你可能会有更好的运气与

            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
            }
或者


未定义mySound。您可能想要更改:

function doclickdiv() {
    soundManager.getSoundById('mySound').play(); 
    // -1 bullet
}

function doclickdiv() {
    soundManager.getSoundById('mySound').play(); 
    // -1 bullet
}
soundManager.createSound({
            id: 'mySound',
            url: 'http://localhost/htmlshooter/mp3/gun.mp3',
            autoLoad: true,
            autoPlay: true,
            volume: 100
        });
var mySound = soundManager.createSound({
            id: 'mySound',
            url: 'http://localhost/htmlshooter/mp3/gun.mp3',
            autoLoad: true,
            autoPlay: true,
            volume: 100
        });