i just started to learn javascript through an online tutorial and downloaded the files from the GitHub repository.The files are of type "easeljs-0.7.1.min".When i typed out the code given below it does not show anything on the browser. Is it a problem of the files I downloaded or of the linking statement ?

<!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>
有帮助吗?

解决方案

All classes in EaselJS are contained in "createjs" namespace, thus, to use Stage or Text classes, just like you are trying to do, you must call createjs first:

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

Result: http://jsfiddle.net/BAv8h/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top