I am going through some tutorials and experimenting with javascript and more particularly EaselJS. I want to create a number of containers which hold images and a text together. But I get the following error: "Uncaught TypeError: undefined is not a function" when I try to add the text and image to the container.
function init() {
stage = new createjs.Stage("demoCanvas");
for(var i=0; i<container.length; i++) { //looping through creation of objects
container[i] = new createjs.Container();
container[i].x = Math.floor(Math.random() * (760 - 40));
img[i] = new createjs.Bitmap (" choc.png" );
container.addChild(img[i]);
txt[i] = new createjs.Text(i, "bold 16px Courier", "#fff");
txt[i].textAlign = "center";
txt[i].y = 50;
container.addChild(txt[i]);
stage.addChild(container[i]);
}
The errors is on the container.addChild(img[i]); line.
Aucun commentaire:
Enregistrer un commentaire