for the start guys thanks for an interesting framework, great job, I'll hope that documentation in the future will be better, in my opinion it lacks real working examples for each object method.
So here is my question, I have a dilemma with with this framework, can some one put a finger on what I did wrong here. I build it from this example. Here is the working code on jsfiddle . Last version should move the rectangle on the canvas.
P.S. It's the same without Container.
var elementOptions = {
stroke: 3,
left: 100,
top: 50,
width: 100,
height: 200,
transformMatrix: [1, 0, 0, 1, 0, 0]
};
function rectElementCanvasObject(options) {
var shape,
rect = new createjs.Graphics()
.setStrokeStyle(options.stroke)
.beginStroke('rgba(255, 0, 0, 0.5)')
.beginFill('rgba(255, 0, 0, 0.5)')
.rect(
options.left,
options.top,
options.width,
options.height);
shape = new createjs.Shape(rect);
if (options.transformMatrix !== undefined) {
shape.transformMatrix = new createjs.Matrix2D(
options.transformMatrix[0],
options.transformMatrix[1],
options.transformMatrix[2],
options.transformMatrix[3],
options.transformMatrix[4],
options.transformMatrix[5]);
}
return shape;
}
$(document).ready(function () {
var canvasId, canvasElement, rectangle, dragger;
canvasId = 'demoCanvas';
canvasElement = new createjs.Stage(canvasId);
canvasElement.mouseMoveOutside = true;
rectangle = rectElementCanvasObject(elementOptions);
dragger = new createjs.Container();
dragger.x = dragger.y = 100;
dragger.addChild(rectangle);
dragger.on("pressmove", function (evt) {
evt.target.x = evt.stageX;
evt.target.y = evt.stageY;
canvasElement.update();
});
dragger.on("pressup", function (evt) {
console.log("up");
});
canvasElement.addChild(dragger);
canvasElement.update();
createjs.Ticker.addEventListener("tick", canvasElement);
});