Javascript stage.update()未使用PRELOERJS定义

Javascript stage.update()未使用PRELOERJS定义,javascript,Javascript,我刚开始使用createjs,我有一个noob问题。在使用PreloderJS预加载图像后,我无法进行图像显示。我的代码: <html> <head> <script src="https://code.createjs.com/easeljs-0.8.0.min.js"></script> <script src="https://code.createjs.com/preloadjs-0.6.0.min.js">&

我刚开始使用createjs,我有一个noob问题。在使用PreloderJS预加载图像后,我无法进行图像显示。我的代码:

<html>
<head>
    <script src="https://code.createjs.com/easeljs-0.8.0.min.js"></script>
     <script src="https://code.createjs.com/preloadjs-0.6.0.min.js"></script>
    <script>
        var queue, bg;
        var stage;
        function init(){
            stage = new createjs.Stage("demoCanvas");
            queue=new createjs.LoadQueue(true);
            queue.on("complete", handleComplete, this);
            queue.loadFile({id:"background", src:"http://localhost/img/mainGameBG.png"});
            queue.load();

        }

        function handleComplete(event){
            bg = queue.getResult("background");
            stage.addChild(bg); //this where console gives red error in chrome
            //document.body.appendChild(bg); //this code works so imageurl is correct
            stage.update(); 
        }
    </script>
</head>
<body onload="init();">

    <canvas id="demoCanvas", width="1000" height="700"></canvas>
</body>

var队列;
var期;
函数init(){
stage=newcreatejs.stage(“demoCanvas”);
queue=new createjs.LoadQueue(true);
排队。在(“完成”,handleComplete,this);
queue.loadFile({id:“后台”,src:)http://localhost/img/mainGameBG.png"});
load();
}
功能处理完成(事件){
bg=queue.getResult(“背景”);
stage.addChild(bg);//控制台在chrome中显示红色错误
//document.body.appendChild(bg);//此代码工作正常,因此imageurl是正确的
stage.update();
}

错误消息:
未捕获InvalidStateError:未能对“EventTarget”执行“dispatchEvent”:提供的事件为空。

url中有一个双斜杠:

queue.loadFile({id:“后台”,src:)http://localhost//img/mainGameBG.png"});


queue.loadFile({id:“后台”,src:)http://localhost/img/mainGameBG.png"});

您必须创建一个新的
位图
,并将其添加到后台:

        bitmap = new createjs.Bitmap(queue.getResult("background"));
        stage.addChild(bitmap);

哦,对不起,我只是在这里发布时删除了部分url。编辑了这篇文章。我的原始文件上有正确的url。