DRBC DRBC - 7 months ago 71
Javascript Question

CreateJS Cannot Read Property 'Get' - TweenJS Demo

I was trying to set up the basic demo of Tween JS, and I'm receiving the error: Uncaught TypeError: Cannot read property 'get' of undefined

JS

function init() {
var stage = new createjs.Stage("demoCanvas");
var circle = new createjs.Shape();
circle.graphics.beginFill("Crimson").drawCircle(0, 0, 50);
circle.x = 100;
circle.y = 100;
stage.addChild(circle);
createjs.Tween.get(circle, {loop: true})
.to({x: 400}, 1000, createjs.Ease.getPowInOut(4))
.to({alpha: 0, y: 75}, 500, createjs.Ease.getPowInOut(2))
.to({alpha: 0, y: 125}, 100)
.to({alpha: 1, y: 100}, 500, createjs.Ease.getPowInOut(2))
.to({x: 100}, 800, createjs.Ease.getPowInOut(2));
createjs.Ticker.setFPS(60);
createjs.Ticker.addEventListener("tick", stage);
}

window.onload = function() {
init();
};

Answer

As Lanny pointed out in the comments, my TweenJS script was not loading. It is not included with EaselJS - make sure to add the script to load the library.

<script src="https://code.createjs.com/tweenjs-0.6.2.min.js"></script>