Вопрос

this is the first time i am using easljs.i've downloaded all the zip file of easljs and extracted it.i wrote some code which will draw a circle on the canvas.but nothing is happening.what i have tried with src gave me an error "creratejs is not defined".i can't figur out hot to add the easljs script to my html code .what should i put in the script src inside the head?please help me out

    <style>
        #mycanvas{
            width:500;
            height:500;
            border:1px solid black;
        }
    </style>

    <script src=""></script>
</head>
<body onload="init();">
<script>
     function init(){
         var stage=new createjs.stage("mycanvas");
         var circle=new createjs.shape();
         circle.graphics.beginFill('red').drawCircle(0,0,50);
         circle.x=100;
         circle.y=100;
         stage.addChild(circle);
         stage.update();
    }
</script>
<canvas id="mycanvas" ></canvas>
</body>
</html>
Это было полезно?

Решение

I notice you have this script tag in the head of your html file <script src=""></script>.

The src attribute is blank and needs to point at your createjs file. If you are running on localhost I would suggest moving createjs into this and then linking to this file.

Make sure that you are waiting for that file to load by having the script tag above the script file where you are using createjs.

Alternatively use the createjs CDN like this:

<script src="http://code.createjs.com/createjs-2013.12.12.min.js"></script>
<script>
    function init() {
        console.log(createjs);
    }

</script>

Read more about the cdn here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top