I am developing an HTML5 application with EaselJS that uses a canvas element covering the entire window to display its interface. I'm using the following function to fix canvas bounds in case user resizes the window:
function resizeCanvas(event) {
if (window.onresize == null) window.onresize = resizeCanvas;
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
stage.update();
}
However, when canvas bounds change, so must some of its elements (children of the createjs.Stage() object). Ideally, I'd like resizeCanvas()
to simply dispatch an event and have the appropriate stage.children()
objects respond. I tried adding the following the line in the above function: stage.dispatchEvent(event)
and creating the shape objects like this:
var grid = new createjs.Shape(drawGrid());
grid.addEventListener('resize', function(evt) { alert(evt); }, false);
stage.addChild(grid);
This, however does not work and it seems I grossly misunderstand Events.