Вопрос

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