EaselJS没有联系

时间:2014-04-17 13:47:44

标签: javascript html5 html5-canvas easeljs

我刚开始通过在线教程学习javascript并从GitHub存储库下载文件。文件类型为“easeljs-0.7.1.min”。当我输入下面给出的代码时,它没有显示任何内容在浏览器上。这是我下载的文件或链接声明的问题吗?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Working</title>

<script src="lib/easeljs-0.7.1.min.js"></script>
<script>
var canvas;
var stage;
var img;
var text;
var logo;

function init()
{
    canvas=document.getElementById("mcanvas");
    stage=new Stage(canvas);
    text=new Text("WHAAAAAAAAA","36px Arial","#666");
    text.x=100;
    text.y=100;
    stage.addChild(text);
    stage.update();
 }
</script> 

<body onload="init();">


<canvas id="mcanvas" width="960" height="500"></canvas>


</body>

1 个答案:

答案 0 :(得分:2)

EaselJS中的所有类都包含在“createjs”命名空间中,因此,要使用Stage或Text类,就像您尝试的那样,您必须首先调用createjs:

stage = new createjs.Stage(canvas);
text = new createjs.Text("WHAAAAAAAAA","36px Arial","#666");

结果:http://jsfiddle.net/BAv8h/