I would like to ask community how to implement addChild function in HTML5 Canvas type in Animate CC.
Here is a very simple scenario:
On the Canvas there are a MovieClip container (by name “imageContainer”) and button (by name “getContent_btn”). The code listed below doesn’t work?
Here is defined functions for image loading using CreateJS
function loadImage() {
var preload = new createjs.LoadQueue();
preload.addEventListener("fileload", handleFileComplete);
preload.loadFile("someimage.png");
}
function handleFileComplete(event) {
this.imageContainer.addChild(event.result);
}
And here is button function and listener
this.getContent_btn.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler()
{
loadImage();
}
function handleFileComplete(event) {
var someid = preload.getResult(“someid”);
var bmp = new createjs.Bitmap(someid);
this_var.container.addChild(bmp);
}
But there is one more detail here. I found that it is possible to use exportRoot instead of this_var.
So this_var.container.addChild(bmp); goes into exportRoot.container.addChild(bmp);